Add control bar option for peertube player
This commit is contained in:
parent
a871d2a273
commit
60f013e103
|
@ -602,6 +602,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
startTime,
|
startTime,
|
||||||
stopTime: urlOptions.stopTime,
|
stopTime: urlOptions.stopTime,
|
||||||
|
controlBar: urlOptions.controlBar,
|
||||||
controls: urlOptions.controls,
|
controls: urlOptions.controls,
|
||||||
muted: urlOptions.muted,
|
muted: urlOptions.muted,
|
||||||
loop: urlOptions.loop,
|
loop: urlOptions.loop,
|
||||||
|
|
|
@ -250,8 +250,8 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<my-peertube-checkbox
|
<my-peertube-checkbox
|
||||||
inputName="controls" [(ngModel)]="customizations.controls"
|
inputName="controlBar" [(ngModel)]="customizations.controlBar"
|
||||||
i18n-labelText labelText="Display player controls"
|
i18n-labelText labelText="Display player control bar"
|
||||||
></my-peertube-checkbox>
|
></my-peertube-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ type Customizations = {
|
||||||
onlyEmbedUrl: boolean
|
onlyEmbedUrl: boolean
|
||||||
title: boolean
|
title: boolean
|
||||||
warningTitle: boolean
|
warningTitle: boolean
|
||||||
controls: boolean
|
controlBar: boolean
|
||||||
peertubeLink: boolean
|
peertubeLink: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ export class VideoShareComponent {
|
||||||
onlyEmbedUrl: false,
|
onlyEmbedUrl: false,
|
||||||
title: true,
|
title: true,
|
||||||
warningTitle: true,
|
warningTitle: true,
|
||||||
controls: true,
|
controlBar: true,
|
||||||
peertubeLink: true
|
peertubeLink: true
|
||||||
}, {
|
}, {
|
||||||
set: (target, prop, value) => {
|
set: (target, prop, value) => {
|
||||||
|
@ -190,7 +190,7 @@ export class VideoShareComponent {
|
||||||
? {
|
? {
|
||||||
title: this.customizations.title,
|
title: this.customizations.title,
|
||||||
warningTitle: this.customizations.warningTitle,
|
warningTitle: this.customizations.warningTitle,
|
||||||
controls: this.customizations.controls,
|
controlBar: this.customizations.controlBar,
|
||||||
peertubeLink: this.customizations.peertubeLink,
|
peertubeLink: this.customizations.peertubeLink,
|
||||||
|
|
||||||
// If using default value, we don't need to specify it
|
// If using default value, we don't need to specify it
|
||||||
|
|
|
@ -110,6 +110,7 @@ export class PeertubePlayerManager {
|
||||||
|
|
||||||
if (isMobile()) player.peertubeMobile()
|
if (isMobile()) player.peertubeMobile()
|
||||||
if (options.common.enableHotkeys === true) player.peerTubeHotkeysPlugin()
|
if (options.common.enableHotkeys === true) player.peerTubeHotkeysPlugin()
|
||||||
|
if (options.common.controlBar === false) player.controlBar.addClass('control-bar-hidden')
|
||||||
|
|
||||||
player.bezels()
|
player.bezels()
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ export interface CustomizationOptions {
|
||||||
stopTime: number | string
|
stopTime: number | string
|
||||||
|
|
||||||
controls?: boolean
|
controls?: boolean
|
||||||
|
controlBar?: boolean
|
||||||
|
|
||||||
muted?: boolean
|
muted?: boolean
|
||||||
loop?: boolean
|
loop?: boolean
|
||||||
subtitle?: string
|
subtitle?: string
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
@use './_player-variables' as *;
|
@use './_player-variables' as *;
|
||||||
|
|
||||||
.video-js.vjs-peertube-skin .vjs-control-bar {
|
.video-js.vjs-peertube-skin .vjs-control-bar {
|
||||||
|
&.control-bar-hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
|
||||||
height: $control-bar-height;
|
height: $control-bar-height;
|
||||||
|
|
|
@ -37,7 +37,10 @@ export class PeerTubeEmbed {
|
||||||
api: PeerTubeEmbedApi = null
|
api: PeerTubeEmbedApi = null
|
||||||
|
|
||||||
autoplay: boolean
|
autoplay: boolean
|
||||||
|
|
||||||
controls: boolean
|
controls: boolean
|
||||||
|
controlBar: boolean
|
||||||
|
|
||||||
muted: boolean
|
muted: boolean
|
||||||
loop: boolean
|
loop: boolean
|
||||||
subtitle: string
|
subtitle: string
|
||||||
|
@ -295,7 +298,10 @@ export class PeerTubeEmbed {
|
||||||
const params = new URL(window.location.toString()).searchParams
|
const params = new URL(window.location.toString()).searchParams
|
||||||
|
|
||||||
this.autoplay = this.getParamToggle(params, 'autoplay', false)
|
this.autoplay = this.getParamToggle(params, 'autoplay', false)
|
||||||
|
|
||||||
this.controls = this.getParamToggle(params, 'controls', true)
|
this.controls = this.getParamToggle(params, 'controls', true)
|
||||||
|
this.controlBar = this.getParamToggle(params, 'controlBar', true)
|
||||||
|
|
||||||
this.muted = this.getParamToggle(params, 'muted', undefined)
|
this.muted = this.getParamToggle(params, 'muted', undefined)
|
||||||
this.loop = this.getParamToggle(params, 'loop', false)
|
this.loop = this.getParamToggle(params, 'loop', false)
|
||||||
this.title = this.getParamToggle(params, 'title', true)
|
this.title = this.getParamToggle(params, 'title', true)
|
||||||
|
@ -539,7 +545,10 @@ export class PeerTubeEmbed {
|
||||||
common: {
|
common: {
|
||||||
// Autoplay in playlist mode
|
// Autoplay in playlist mode
|
||||||
autoplay: alreadyHadPlayer ? true : this.autoplay,
|
autoplay: alreadyHadPlayer ? true : this.autoplay,
|
||||||
|
|
||||||
controls: this.controls,
|
controls: this.controls,
|
||||||
|
controlBar: this.controlBar,
|
||||||
|
|
||||||
muted: this.muted,
|
muted: this.muted,
|
||||||
loop: this.loop,
|
loop: this.loop,
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,10 @@ function decorateVideoLink (options: {
|
||||||
// Embed options
|
// Embed options
|
||||||
title?: boolean
|
title?: boolean
|
||||||
warningTitle?: boolean
|
warningTitle?: boolean
|
||||||
|
|
||||||
controls?: boolean
|
controls?: boolean
|
||||||
|
controlBar?: boolean
|
||||||
|
|
||||||
peertubeLink?: boolean
|
peertubeLink?: boolean
|
||||||
p2p?: boolean
|
p2p?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
@ -73,7 +76,10 @@ function decorateVideoLink (options: {
|
||||||
if (options.muted === true) params.set('muted', '1')
|
if (options.muted === true) params.set('muted', '1')
|
||||||
if (options.title === false) params.set('title', '0')
|
if (options.title === false) params.set('title', '0')
|
||||||
if (options.warningTitle === false) params.set('warningTitle', '0')
|
if (options.warningTitle === false) params.set('warningTitle', '0')
|
||||||
|
|
||||||
if (options.controls === false) params.set('controls', '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.peertubeLink === false) params.set('peertubeLink', '0')
|
||||||
if (options.p2p !== undefined) params.set('p2p', options.p2p ? '1' : '0')
|
if (options.p2p !== undefined) params.set('p2p', options.p2p ? '1' : '0')
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,59 @@ player.seek(32)
|
||||||
player.pause()
|
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
|
# Methods
|
||||||
|
|
||||||
## `play() : Promise<void>`
|
## `play() : Promise<void>`
|
||||||
|
|
Loading…
Reference in New Issue