Skip to content

Commit

Permalink
id3Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoLC committed Dec 21, 2023
1 parent a4bbf9c commit 35d53db
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export const createVideojsPlayer = (

onReady?.(player);

console.log('player', { player });

// plugins initialization
if (isMSESupported()) {
if (isP2pQueryEnabled && isP2PEnabled) {
Expand All @@ -127,9 +129,9 @@ export const createVideojsPlayer = (
});
}
player.transcriptPlugin({ video });
// player.httpSourceSelector();
//player.httpSourceSelector();
}
// player.id3Plugin();
player.id3Plugin();
// player.xapiPlugin({ video, locale, dispatchPlayerTimeUpdate });

return player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import { Id3VideoType, useVideo } from 'lib-components';
import videojs from 'video.js';
const Plugin = videojs.getPlugin('plugin');
import videojs, { Player } from 'video.js';

import { id3PluginType } from './type';

type Id3MessageType = {
video: Id3VideoType;
};

export class id3Plugin extends Plugin {
const PluginClass = videojs.getPlugin('plugin') as id3PluginType;

export class id3Plugin extends PluginClass {
lastReceivedVideo: Id3VideoType | undefined;
videoState;
declare player: Player;

constructor(player: videojs.Player, options: unknown) {
constructor(player: Player, options: unknown) {
super(player, options);

this.videoState = useVideo.getState();
this.videoState.setIsWatchingVideo(true);

player.on('loadedmetadata', this.handleLoadedMetadata.bind(this));
this.player.on('loadedmetadata', this.handleLoadedMetadata.bind(this));

player.on('play', this.handleStart.bind(this));
this.player.on('play', this.handleStart.bind(this));

player.on('ended', this.handleEnded.bind(this));
this.player.on('ended', this.handleEnded.bind(this));

player.on('dispose', this.handleDispose.bind(this));
this.player.on('dispose', this.handleDispose.bind(this));
}

handleLoadedMetadata() {
console.log('handleLoadedMetadata', this.player);

const tracks = this.player.textTracks();
for (let index = 0; index < tracks.length; index++) {
const track = tracks[index];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import videojs, { Player } from 'video.js';
import PluginType from 'video.js/dist/types/plugin';

const Plugin = videojs.getPlugin('plugin') as typeof PluginType;
export class id3PluginClass extends Plugin {
declare player: Player;

constructor(player: Player, _options?: unknown) {
super(player);
}
}

export type id3PluginType = typeof id3PluginClass;
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
DownloadVideoPluginOptions,
SharedLiveMediaOptions,
TranscriptButtonOptions,
//QualitySelectorOptions,
XapiPluginOptions,
} from '../../../components/common/Player/videojs/';
// import { TranscriptPluginOptions } from '../../../components/common/Player/videojs/transcriptPlugin/types';
// import { XapiPluginOptions } from '../../../components/common/Player/videojs/xapiPlugin/types';

declare module 'video.js' {
export function MiddlewareUse(
Expand Down Expand Up @@ -147,6 +146,10 @@ declare module 'video.js' {
downloadVideoPlugin: (options: DownloadVideoPluginOptions) => void;
sharedMediaPlugin: (options: SharedLiveMediaOptions) => void;
transcriptPlugin: (option: TranscriptPluginOptions) => void;
httpSourceSelector: () => void;
id3Plugin: () => void;
textTracks: () => TextTrackList;
//xapiPlugin: (options: XapiPluginOptions) => void;
}

// function createPlayer(
Expand Down

0 comments on commit 35d53db

Please sign in to comment.