]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add control bar option for peertube player
authorChocobozzz <me@florianbigard.com>
Fri, 20 May 2022 07:59:53 +0000 (09:59 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 20 May 2022 07:59:53 +0000 (09:59 +0200)
client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/app/shared/shared-share-modal/video-share.component.html
client/src/app/shared/shared-share-modal/video-share.component.ts
client/src/assets/player/peertube-player-manager.ts
client/src/assets/player/types/manager-options.ts
client/src/sass/player/control-bar.scss
client/src/standalone/videos/embed.ts
shared/core-utils/common/url.ts
support/doc/api/embeds.md

index 61b4408595edde56f1768241681608d4daf24c70..5fa31ec63bb51d2f05159ee860cea05415352e27 100644 (file)
@@ -602,6 +602,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
         startTime,
         stopTime: urlOptions.stopTime,
+        controlBar: urlOptions.controlBar,
         controls: urlOptions.controls,
         muted: urlOptions.muted,
         loop: urlOptions.loop,
index 7ff62e128661e64adcb5f939ce5ce03bf3bd105f..67ca56516e7dc56e66d479954a3894ffd3ac8841 100644 (file)
 
             <div class="form-group">
               <my-peertube-checkbox
-                inputName="controls" [(ngModel)]="customizations.controls"
-                i18n-labelText labelText="Display player controls"
+                inputName="controlBar" [(ngModel)]="customizations.controlBar"
+                i18n-labelText labelText="Display player control bar"
               ></my-peertube-checkbox>
             </div>
 
index 6c0d4a0398a2dcf7c71070ecb9af28e1ed401893..e0c98008cb79f4d1304602807b9e1ed5c2c6ce8d 100644 (file)
@@ -27,7 +27,7 @@ type Customizations = {
   onlyEmbedUrl: boolean
   title: boolean
   warningTitle: boolean
-  controls: boolean
+  controlBar: boolean
   peertubeLink: boolean
 }
 
@@ -88,7 +88,7 @@ export class VideoShareComponent {
       onlyEmbedUrl: false,
       title: true,
       warningTitle: true,
-      controls: true,
+      controlBar: true,
       peertubeLink: true
     }, {
       set: (target, prop, value) => {
@@ -190,7 +190,7 @@ export class VideoShareComponent {
       ? {
         title: this.customizations.title,
         warningTitle: this.customizations.warningTitle,
-        controls: this.customizations.controls,
+        controlBar: this.customizations.controlBar,
         peertubeLink: this.customizations.peertubeLink,
 
         // If using default value, we don't need to specify it
index 1b2a67c770446aabdee69a025934949973e27383..b24b6966eb6272defb5617b47211edc0e27efd89 100644 (file)
@@ -110,6 +110,7 @@ export class PeertubePlayerManager {
 
         if (isMobile()) player.peertubeMobile()
         if (options.common.enableHotkeys === true) player.peerTubeHotkeysPlugin()
+        if (options.common.controlBar === false) player.controlBar.addClass('control-bar-hidden')
 
         player.bezels()
 
index 456ef115ef9a6a712c6237e5e3ac44fe408f4c15..a6f00876f451a89e94a7a44e64fe3f3698dbc029 100644 (file)
@@ -21,6 +21,8 @@ export interface CustomizationOptions {
   stopTime: number | string
 
   controls?: boolean
+  controlBar?: boolean
+
   muted?: boolean
   loop?: boolean
   subtitle?: string
index 9b35c6cb29e0c3805e9bd626b3f9c5e8e12fb23b..56102d3fbf5fc5f07029a790544a3a11bfd74d57 100644 (file)
@@ -4,6 +4,10 @@
 @use './_player-variables' as *;
 
 .video-js.vjs-peertube-skin .vjs-control-bar {
+  &.control-bar-hidden {
+    display: none !important;
+  }
+
   z-index: 100;
 
   height: $control-bar-height;
index c0af1dfb33c69dcdca7af2ca7bba34c7e5bb4e92..1fc8e229b2f79eaa9cc50236e30f66b925abdca5 100644 (file)
@@ -37,7 +37,10 @@ export class PeerTubeEmbed {
   api: PeerTubeEmbedApi = null
 
   autoplay: boolean
+
   controls: boolean
+  controlBar: boolean
+
   muted: boolean
   loop: boolean
   subtitle: string
@@ -295,7 +298,10 @@ export class PeerTubeEmbed {
       const params = new URL(window.location.toString()).searchParams
 
       this.autoplay = this.getParamToggle(params, 'autoplay', false)
+
       this.controls = this.getParamToggle(params, 'controls', true)
+      this.controlBar = this.getParamToggle(params, 'controlBar', true)
+
       this.muted = this.getParamToggle(params, 'muted', undefined)
       this.loop = this.getParamToggle(params, 'loop', false)
       this.title = this.getParamToggle(params, 'title', true)
@@ -539,7 +545,10 @@ export class PeerTubeEmbed {
       common: {
         // Autoplay in playlist mode
         autoplay: alreadyHadPlayer ? true : this.autoplay,
+
         controls: this.controls,
+        controlBar: this.controlBar,
+
         muted: this.muted,
         loop: this.loop,
 
index 8020d9b28e7f984e8d56ea74d3f4b4da99c85a44..fd54e7594c10246ce4b1022a32cae892a5be5791 100644 (file)
@@ -48,7 +48,10 @@ function decorateVideoLink (options: {
   // Embed options
   title?: boolean
   warningTitle?: boolean
+
   controls?: boolean
+  controlBar?: boolean
+
   peertubeLink?: boolean
   p2p?: boolean
 }) {
@@ -73,7 +76,10 @@ function decorateVideoLink (options: {
   if (options.muted === true) params.set('muted', '1')
   if (options.title === false) params.set('title', '0')
   if (options.warningTitle === false) params.set('warningTitle', '0')
+
   if (options.controls === false) params.set('controls', '0')
+  if (options.controlBar === false) params.set('controlBar', '0')
+
   if (options.peertubeLink === false) params.set('peertubeLink', '0')
   if (options.p2p !== undefined) params.set('p2p', options.p2p ? '1' : '0')
 
index d64615764edab58af4d4677d691dab6344c583a5..bc3b5304c39f59d067263b7ce15d6b97c578548e 100644 (file)
@@ -49,6 +49,59 @@ player.seek(32)
 player.pause()
 ```
 
+# URL parameters
+
+You can customize PeerTube player by specifying URL query parameters.
+For example `https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a??start=1s&stop=18s&loop=1&autoplay=1&muted=1&warningTitle=0&controlBar=0&peertubeLink=0&p2p=0`
+
+## start
+
+Start the video at a specific time.
+Value must be raw seconds or a duration (`3m4s`)
+
+## stop
+
+Stop the video at a specific time.
+Value must be raw seconds or a duration (`54s`)
+
+## controls
+
+Mimics video HTML element `controls` attribute, meaning that all controls (including big play button, control bar, etc.) will be removed.
+It can be useful if you want to have a full control of the PeerTube player.
+
+Value must be `0` or `1`.
+
+## controlBar
+
+Hide control bar when the video is played.
+
+Value must be `0` or `1`.
+
+## peertubeLink
+
+Hide PeerTube link in control bar.
+
+Value must be `0` or `1`.
+
+## muted
+
+Mute the video by default.
+
+Value must be `0` or `1`.
+
+## loop
+
+Automatically start again the video when it ends.
+
+Value must be `0` or `1`.
+
+## subtitle
+
+Auto select a subtitle by default.
+
+Value must be a valid subtitle ISO code (`fr`, `en`, etc.).
+
+
 # Methods
 
 ## `play() : Promise<void>`