Put instance name in embed button

This commit is contained in:
Chocobozzz 2022-06-28 14:04:03 +02:00
parent 9f4109e263
commit bd2b51be4b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
9 changed files with 37 additions and 24 deletions

View File

@ -627,6 +627,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
embedUrl: video.embedUrl, embedUrl: video.embedUrl,
embedTitle: video.name, embedTitle: video.name,
instanceName: this.serverConfig.instance.name,
isLive: video.isLive, isLive: video.isLive,
liveOptions, liveOptions,

View File

@ -5,6 +5,8 @@ import { PeerTubeLinkButtonOptions } from '../../types'
const Button = videojs.getComponent('Button') const Button = videojs.getComponent('Button')
class PeerTubeLinkButton extends Button { class PeerTubeLinkButton extends Button {
private instanceName: string
constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) { constructor (player: videojs.Player, options?: PeerTubeLinkButtonOptions) {
super(player, options as any) super(player, options as any)
} }
@ -24,7 +26,7 @@ class PeerTubeLinkButton extends Button {
private buildElement () { private buildElement () {
const el = videojs.dom.createEl('a', { const el = videojs.dom.createEl('a', {
href: this.buildLink(), href: this.buildLink(),
innerHTML: 'PeerTube', innerHTML: (this.options_ as PeerTubeLinkButtonOptions).instanceName,
title: this.player().localize('Video page (new window)'), title: this.player().localize('Video page (new window)'),
className: 'vjs-peertube-link', className: 'vjs-peertube-link',
target: '_blank' target: '_blank'

View File

@ -51,7 +51,10 @@ export class ControlBarOptionsBuilder {
if (this.options.peertubeLink === true) { if (this.options.peertubeLink === true) {
Object.assign(children, { Object.assign(children, {
peerTubeLinkButton: { shortUUID: this.options.videoShortUUID } as PeerTubeLinkButtonOptions peerTubeLinkButton: {
shortUUID: this.options.videoShortUUID,
instanceName: this.options.instanceName
} as PeerTubeLinkButtonOptions
}) })
} }

View File

@ -51,6 +51,8 @@ export interface CommonOptions extends CustomizationOptions {
inactivityTimeout: number inactivityTimeout: number
poster: string poster: string
instanceName: string
theaterButton: boolean theaterButton: boolean
captions: boolean captions: boolean

View File

@ -127,6 +127,7 @@ type NextPreviousVideoButtonOptions = {
type PeerTubeLinkButtonOptions = { type PeerTubeLinkButtonOptions = {
shortUUID: string shortUUID: string
instanceName: string
} }
type PeerTubeP2PInfoButtonOptions = { type PeerTubeP2PInfoButtonOptions = {

View File

@ -160,8 +160,8 @@
.vjs-peertube { .vjs-peertube {
@include margin-right(6px); @include margin-right(6px);
@include margin-left(auto);
width: 100%;
line-height: $control-bar-height; line-height: $control-bar-height;
text-align: end; text-align: end;
overflow: hidden; overflow: hidden;
@ -358,11 +358,13 @@
.vjs-peertube-link { .vjs-peertube-link {
@include disable-outline; @include disable-outline;
@include disable-default-a-behaviour; @include disable-default-a-behaviour;
@include ellipsis;
text-decoration: none; text-decoration: none;
line-height: $control-bar-height; line-height: $control-bar-height;
font-weight: $font-semibold; font-weight: $font-semibold;
padding: 0 5px; padding: 0 5px;
max-width: 150px;
} }
.vjs-theater-control { .vjs-theater-control {
@ -420,6 +422,10 @@
} }
@media screen and (max-width: $screen-width-570) { @media screen and (max-width: $screen-width-570) {
.vjs-volume-control {
display: none;
}
.vjs-peertube { .vjs-peertube {
padding: 0 !important; padding: 0 !important;
@ -428,6 +434,10 @@
} }
} }
.vjs-peertube-link {
max-width: 100px;
}
&.vjs-live { &.vjs-live {
.vjs-duration { .vjs-duration {
display: none !important; display: none !important;
@ -440,7 +450,6 @@
} }
@media screen and (max-width: $screen-width-350) { @media screen and (max-width: $screen-width-350) {
.vjs-volume-control,
.vjs-next-video, .vjs-next-video,
.vjs-previous-video { .vjs-previous-video {
display: none !important; display: none !important;
@ -458,6 +467,12 @@
@include margin-right($first-control-bar-element-margin-left-small-width); @include margin-right($first-control-bar-element-margin-left-small-width);
} }
.vjs-play-control {
@include margin-left(0);
width: 30px;
}
&.vjs-live { &.vjs-live {
.vjs-current-time { .vjs-current-time {
display: none !important; display: none !important;

View File

@ -40,25 +40,6 @@ body {
.vjs-poster { .vjs-poster {
background-size: 100% auto; background-size: 100% auto;
} }
@media screen and (max-width: 350px) {
.vjs-play-control {
padding: 0 5px !important;
width: 25px !important;
}
.vjs-volume-control {
display: none !important;
}
.vjs-volume-panel {
width: 26px !important;
}
.vjs-peertube-link {
padding: 0;
}
}
} }
#error-block { #error-block {

View File

@ -196,6 +196,8 @@ export class PeerTubeEmbed {
captionsResponse, captionsResponse,
alreadyHadPlayer, alreadyHadPlayer,
translations, translations,
serverConfig: this.config,
onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer(uuid), onVideoUpdate: (uuid: string) => this.loadVideoAndBuildPlayer(uuid),
playlistTracker: this.playlistTracker, playlistTracker: this.playlistTracker,

View File

@ -148,6 +148,8 @@ export class PlayerManagerOptions {
captionsResponse: Response captionsResponse: Response
live?: LiveVideo live?: LiveVideo
serverConfig: HTMLServerConfig
alreadyHadPlayer: boolean alreadyHadPlayer: boolean
translations: Translations translations: Translations
@ -163,7 +165,8 @@ export class PlayerManagerOptions {
alreadyHadPlayer, alreadyHadPlayer,
translations, translations,
playlistTracker, playlistTracker,
live live,
serverConfig
} = options } = options
const videoCaptions = await this.buildCaptions(captionsResponse, translations) const videoCaptions = await this.buildCaptions(captionsResponse, translations)
@ -205,7 +208,10 @@ export class PlayerManagerOptions {
videoDuration: video.duration, videoDuration: video.duration,
enableHotkeys: true, enableHotkeys: true,
peertubeLink: this.peertubeLink, peertubeLink: this.peertubeLink,
instanceName: serverConfig.instance.name,
poster: window.location.origin + video.previewPath, poster: window.location.origin + video.previewPath,
theaterButton: false, theaterButton: false,