@ldelia/react-media 0.5.9 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { Reproduction } from './models/Reproduction';
3
3
  interface BaseProps {
4
4
  trainingMode: boolean;
5
+ withCountingIn?: boolean;
5
6
  songTempo?: number;
6
7
  onInit: (reproduction: Reproduction) => void;
7
8
  }
@@ -16,5 +17,5 @@ interface NonTrainingProps extends BaseProps {
16
17
  videoId?: never;
17
18
  }
18
19
  export type ReproductionWidgetProps = TrainingProps | NonTrainingProps;
19
- export declare const ReproductionWidget: ({ trainingMode, duration, videoId, songTempo, onInit, }: ReproductionWidgetProps) => React.JSX.Element;
20
+ export declare const ReproductionWidget: ({ trainingMode, duration, videoId, withCountingIn, songTempo, onInit, }: ReproductionWidgetProps) => React.JSX.Element;
20
21
  export {};
@@ -2,13 +2,13 @@ import React from 'react';
2
2
  import { YouTubeInnerPlayer } from './inner-players/YouTubeInnerPlayer';
3
3
  import { PlayAlongInnerPlayer } from './inner-players/PlayAlongInnerPlayer';
4
4
  import { Reproduction } from './models/Reproduction';
5
- export const ReproductionWidget = ({ trainingMode, duration, videoId, songTempo = 0, onInit, }) => {
5
+ export const ReproductionWidget = ({ trainingMode, duration, videoId, withCountingIn = true, songTempo = 0, onInit, }) => {
6
6
  function onPlayAlongInnerPlayerReadyHandler(event) {
7
7
  let newReproduction = Reproduction.newBuilder()
8
8
  .withTrainingMode(false)
9
9
  .withSongDuration(duration)
10
10
  .withSongTempo(songTempo)
11
- .withCountingIn(songTempo > 0)
11
+ .withCountingIn(withCountingIn && songTempo > 0)
12
12
  .withInnerPlayer(event.target)
13
13
  .createReproduction();
14
14
  onInit(newReproduction);
@@ -17,7 +17,7 @@ export const ReproductionWidget = ({ trainingMode, duration, videoId, songTempo
17
17
  let newReproduction = Reproduction.newBuilder()
18
18
  .withTrainingMode(true)
19
19
  .withSongTempo(songTempo)
20
- .withCountingIn(songTempo > 0)
20
+ .withCountingIn(withCountingIn && songTempo > 0)
21
21
  .withInnerPlayer(event.target)
22
22
  .createReproduction();
23
23
  onInit(newReproduction);
@@ -1,5 +1,13 @@
1
1
  import React from 'react';
2
2
  import ReactPlayer from 'react-player/lazy';
3
3
  export const YouTubeInnerPlayer = ({ videoId, onReady }) => {
4
- return (React.createElement(ReactPlayer, { url: `https://www.youtube.com/watch?v=${videoId}`, onReady: (event) => onReady({ target: event.getInternalPlayer() }) }));
4
+ return (React.createElement(ReactPlayer, { url: `https://www.youtube.com/watch?v=${videoId}`, onReady: (event) => {
5
+ // Remove focus from the iframe
6
+ // This is a workaround for a bug in react-player https://github.com/cookpete/react-player/issues/1124
7
+ const internalPlayer = event.getInternalPlayer();
8
+ const iframe = internalPlayer.getIframe();
9
+ iframe.tabIndex = -1;
10
+ // Propagate internal player
11
+ onReady({ target: event.getInternalPlayer() });
12
+ } }));
5
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldelia/react-media",
3
- "version": "0.5.9",
3
+ "version": "0.5.11",
4
4
  "description": "A React components collection for media-related features.",
5
5
  "private": false,
6
6
  "keywords": [