X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fstandalone%2Fvideos%2Fembed-api.ts;h=75174f2f8ef2a6eca1362ab52db7d3e7b8234001;hb=adb8809d43648ea0a64d6845bb39aa3bd0e005a6;hp=a9263555d839e400b6e12292a3e000eff8eafff9;hpb=1151f5210c0e7665ec6714e73261f299e6fe757b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts index a9263555d..75174f2f8 100644 --- a/client/src/standalone/videos/embed-api.ts +++ b/client/src/standalone/videos/embed-api.ts @@ -26,7 +26,7 @@ export class PeerTubeEmbedApi { } private get element () { - return this.embed.videoElement + return this.embed.playerElement } private constructChannel () { @@ -50,6 +50,10 @@ export class PeerTubeEmbedApi { channel.bind('setPlaybackRate', (txn, playbackRate) => this.embed.player.playbackRate(playbackRate)) channel.bind('getPlaybackRate', (txn, params) => this.embed.player.playbackRate()) channel.bind('getPlaybackRates', (txn, params) => this.embed.player.options_.playbackRates) + + channel.bind('playNextVideo', (txn, params) => this.embed.playNextVideo()) + channel.bind('playPreviousVideo', (txn, params) => this.embed.playPreviousVideo()) + channel.bind('getCurrentPosition', (txn, params) => this.embed.getCurrentPosition()) this.channel = channel } @@ -108,7 +112,6 @@ export class PeerTubeEmbedApi { setInterval(() => { const position = this.element.currentTime const volume = this.element.volume - const duration = this.element.duration this.channel.notify({ method: 'playbackStatusUpdate', @@ -137,12 +140,14 @@ export class PeerTubeEmbedApi { }) // PeerTube specific capabilities - if (this.isWebtorrent()) { this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions()) this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions()) + + this.loadWebTorrentResolutions() } else { this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions()) + this.embed.player.p2pMediaLoader().on('resolutionsLoaded', () => this.loadP2PMediaLoaderResolutions()) } this.embed.player.on('volumechange', () => { @@ -204,6 +209,6 @@ export class PeerTubeEmbedApi { } private isWebtorrent () { - return this.embed.player.webtorrent + return !!this.embed.player.webtorrent } }