video.js: ensure example class-based plugin works (#43558)

* ensure example class-based plugin works

* additional test to be sure Plugin has player property
This commit is contained in:
Joe Flateau 2020-04-01 15:46:22 -04:00 committed by GitHub
parent 93d70f87d5
commit 8b4734fb5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View File

@ -3954,7 +3954,7 @@ declare namespace videojs {
* @param player
* A Video.js player instance.
*/
new(player: Player): Plugin;
new (player: Player, options?: any): Plugin;
/**
* De-register a Video.js plugin.

View File

@ -1,4 +1,4 @@
import videojs from 'video.js';
import videojs, { VideoJsPlayer } from 'video.js';
videojs("example_video_1").ready(function() {
// EXAMPLE: Start playing the video.
@ -131,6 +131,32 @@ function testPlugin(player: videojs.Player, options: {}) {
});
});
(player as any).uloztoExample(options);
const Plugin = videojs.getPlugin('plugin');
interface ExamplePluginOptions {
customClass: string;
}
class ExamplePlugin extends Plugin {
constructor(player: VideoJsPlayer, options: ExamplePluginOptions) {
super(player, options);
if (options.customClass) {
player.addClass(options.customClass);
}
player.on('playing', () => {
videojs.log('playback began!');
});
this.player.on('pause', () => {
videojs.log('playback ended');
});
}
}
videojs.registerPlugin('ExamplePlugin', ExamplePlugin);
}
function testLogger() {