]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/player/player.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / standalone / player / player.ts
index 71c41295076db65bdc1a8e36c1e97510deaa6007..9776fda120297fbfd21966203cfd66f5eb65aeb1 100644 (file)
@@ -1,6 +1,6 @@
 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',
@@ -104,6 +104,21 @@ export class PeerTubePlayer {
     return this.sendMessage<void, number>('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<PeerTubeTextTrack[]> {
+    return this.sendMessage<void, PeerTubeTextTrack[]>('getCaptions')
+  }
+
   /**
    * Tell the embed to seek to a specific position (in seconds)
    * @param seconds
@@ -155,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<void, number>('getCurrentPosition')
+  }
+
   private constructChannel () {
     this.channel = Channel.build({
       window: this.embedElement.contentWindow,