Skip to content

MiniPlayer : Added Mini player component. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Sidharth-iOS
Copy link
Contributor

Added Mini player component using existing Native api's.

* @returns {string} title to display
*/
export const getTitleFromVideoInfo = ({ title, castingTo }) => {
if (title && title.length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use optional chaining operator e.g., title?.length

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

index.js Outdated
export { default as VizbeeTrackInfo } from "./VizbeeTrackInfo";
export const VizbeeCastButton = requireNativeComponent("VizbeeCastButtonView");
export { default as VizbeeMiniCastBar } from "./src/mini-cast-bar";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move it to the "components" folder, something like this "./src/components/mini-cast-bar"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, The convention widely adopted is PascalCase (UpperCamelCase) for component names and folder structures. Can you recheck on this rename to VizbeeMiniCastBar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that now it's exported as export { VizbeeMiniCastBar } which enforces using the specified name when other modules want to import it. I think we should give flexibility to other modules in choosing a name during the import

const percentage = (streamPosition / streamDuration) * 100;


return isVisible ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this functional component to a .js file something like VZBMiniCastBarComponent.js as It's not a common best practice to write a functional component directly in the index.js file of a React application?

src
|-- components
|   |-- mini-cast-bar
|       |-- hooks
|          |-- index.js
|          |-- useMiniPlayerStyleHook
|          |-- ...
|       |-- index.js
|       |-- VZBMiniCastBarComponent.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,6 @@

export {useMiniPlayerMediaStatusListenerHook} from "./useMiniPlayerMediaStatusListenerHook"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the broad architecture we are following here is the functional components with hooks and for new development, it's often recommended to use functional components with hooks.

The only concern I have is that both hooks and functional components were introduced in RN 0.59 but the peerDependencies that we added in our react-native-wrapper package is 0.41.2.

  1. Should we update our peerDependencies to 0.59?
  2. If so, any existing customers who are on <0.59 are forced to update to 0.59, can we validate this by preparing list of customer who are using our react-native wrapper and what version of react-native they are on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whom should i ask for point 2?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with the following list for now
Tegna - we will get it
NFL > 0.59
NewsON > 0.59


public void setAppTheme(@StyleRes int theme) {
VizbeeContext.getInstance().setTheme(theme);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change if it's only used in the demo app. Apps can directly call
VizbeeContext.getInstance().setTheme(theme); in their java files. Add vizbee-sender-sdk as a dependency to the apps module if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure apps has access to VizbeeContext because i didn't have access to it from the wrapper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apps have to add the dependency of native SDK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok got it

STOP: "stop",
};

export const LOG_TAG = "MiniPlayer"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change log tag to VZBRNSDK_MiniCastBar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,36 @@
import { VizbeeManager } from "../../../";
import { ButtonType } from "../constants";
import { LOG_TAG } from "../constants";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's update the import to import { ButtonType, LOG_TAG } from "../constants";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

default:
break;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need for outer function? can't it be written simply like the following?

const onButtonPress = (buttonType) => {
  console.debug(LOG_TAG, `Miniplayer control pressed :: ${buttonType}.`);
  switch (buttonType) {
    case ButtonType.PLAY:
      VizbeeManager.play();
      break;
    case ButtonType.PAUSE:
      VizbeeManager.pause();
      break;
    case ButtonType.STOP:
      VizbeeManager.stop();
      break;
    default:
      break;
  }
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* Called on Miniplayer View press
*/
const onMiniPlayerViewPress = () => {
console.debug(LOG_TAG, `Miniplayer View pressed`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use template literals consistently
console.debug(`${LOG_TAG} Miniplayer View pressed`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
const onButtonPress = (buttonType) =>
function () {
console.debug(LOG_TAG, `Miniplayer control pressed :: ${buttonType}.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use template literals consistently
console.debug(`${LOG_TAG} Miniplayer control pressed :: ${buttonType}.`);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import { ButtonType } from "../constants";
import { LOG_TAG } from "../constants";

export const useMiniPlayerActionsHook = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments to explain the purpose of the hook and the main functions. Make sure you add the same for all the hooks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

VizbeePlayerState,
} from "../../../";
import { ButtonType } from "../constants";
import { LOG_TAG } from "../constants";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return;
}

if (newMediaStatus?.playerState === VizbeePlayerState.Paused || newMediaStatus?.playerState === VizbeePlayerState.Loading || newMediaStatus?.playerState === VizbeePlayerState.Buffering) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NitPick: let's break it down to multi line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import { ButtonType } from "../constants";
import { LOG_TAG } from "../constants";

export const useMiniPlayerMediaStatusListenerHook = ({
Copy link
Contributor

@shivareddy shivareddy Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use consistent naming starting from Component folder name to hooks use MiniCastBar
say,

  1. For component folder name VizbeeMiniCastBar
  2. For functional component name VizbeeMiniCastBar.js
  3. For hooks useMiniCastBarMediaStatusListenerHook.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

case VizbeePlayerState.Stopped:
case VizbeePlayerState.Stopped_On_Disconnect:
case VizbeePlayerState.Ended:
// Receiving started event with empty title and subtitle so remo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NitPick: finish the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @returns {string} title to display
*/
export const getTitleFromVideoInfo = ({title, castingTo}) => {
if (title && title?.length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?. is optional chaining operator is already used here. So no need to check title. Please change title && title?.length to title?.length

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

* @returns {string} subtitle to display
*/
export const getSubTitleFromVideoInfo = ({title, subTitle, castingTo}) => {
if (subTitle && subTitle?.length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change if (subTitle && subTitle?.length) to if (subTitle?.length) and if (title && title?.length) to if(title?.length)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*
* @returns {Object} default color object
*/
export function getApperanceColor(isDark) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this typo? getApperanceColor --> getAppearanceColor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

console.debug(
`${LOG_TAG} Media status current state :: ${newMediaStatus.playerState}`
);
if (newMediaStatus?.guid && newMediaStatus?.guid?.length != 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: Change if (newMediaStatus?.guid && newMediaStatus?.guid?.length != 0) to if(newMediaStatus?.guid?.length != 0)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}) => {
const isDark = Appearance.getColorScheme() === "dark";

const defaultApperance = getApperanceColor(isDark);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this typo? defaultApperance --> defaultAppearanceandgetApperanceColor-->getAppearanceColor`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,41 @@
import { VizbeeManager } from "../../../../";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a react custom hook? We are not using any react APIs like useState or useEffect or anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no need of it in this hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants