X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fstandalone%2Fplayer%2Fplayer.ts;h=9776fda120297fbfd21966203cfd66f5eb65aeb1;hb=35f676e5d3e5e242e84ed63da2cc78117079c7cb;hp=91a5e73f3e921de349817f6de2c06d42af306258;hpb=902aa3a099638b2198c24c076c61577a8435277b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/standalone/player/player.ts b/client/src/standalone/player/player.ts index 91a5e73f3..9776fda12 100644 --- a/client/src/standalone/player/player.ts +++ b/client/src/standalone/player/player.ts @@ -1,13 +1,14 @@ import * as Channel from 'jschannel' +import { EventHandler, PeerTubeResolution, PeerTubeTextTrack, PlayerEventType } from './definitions' import { EventRegistrar } from './events' -import { EventHandler, PlayerEventType, PeerTubeResolution } from './definitions' const PASSTHROUGH_EVENTS = [ 'pause', 'play', 'playbackStatusUpdate', 'playbackStatusChange', - 'resolutionUpdate' + 'resolutionUpdate', + 'volumeChange' ] /** @@ -100,7 +101,22 @@ export class PeerTubePlayer { * @param value A number from 0 to 1 */ async getVolume (): Promise { - return this.sendMessage('setVolume') + return this.sendMessage('getVolume') + } + + /** + * Tell the embed to change the current caption + * @param value Caption id + */ + async setCaption (value: string) { + await this.sendMessage('setCaption', value) + } + + /** + * Get video captions + */ + async getCaptions (): Promise { + return this.sendMessage('getCaptions') } /** @@ -154,6 +170,27 @@ export class PeerTubePlayer { await this.sendMessage('setPlaybackRate', rate) } + /** + * Play next video in playlist + */ + async playNextVideo () { + await this.sendMessage('playNextVideo') + } + + /** + * Play previous video in playlist + */ + async playPreviousVideo () { + await this.sendMessage('playPreviousVideo') + } + + /** + * Get video position currently played (starts from 1) + */ + async getCurrentPosition () { + return this.sendMessage('getCurrentPosition') + } + private constructChannel () { this.channel = Channel.build({ window: this.embedElement.contentWindow, @@ -191,4 +228,4 @@ export class PeerTubePlayer { } // put it on the window as well as the export -window[ 'PeerTubePlayer' ] = PeerTubePlayer +(window[ 'PeerTubePlayer' ] as any) = PeerTubePlayer