Improve first play

This commit is contained in:
Chocobozzz 2018-04-03 15:11:46 +02:00
parent c6352f2c64
commit 33d7855229
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 42 additions and 19 deletions

View File

@ -1,7 +1,7 @@
<div class="row"> <div class="row">
<!-- We need the video container for videojs so we just hide it --> <!-- We need the video container for videojs so we just hide it -->
<div [hidden]="videoNotFound" id="video-container"> <div [hidden]="videoNotFound" id="video-container">
<video [poster]="getVideoPoster()" id="video-element" class="video-js vjs-peertube-skin"></video> <video id="video-element" class="video-js vjs-peertube-skin"></video>
</div> </div>
<div *ngIf="videoNotFound" id="video-not-found">Video not found :'(</div> <div *ngIf="videoNotFound" id="video-not-found">Video not found :'(</div>

View File

@ -337,11 +337,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
if (this.videoPlayerLoaded !== true) { if (this.videoPlayerLoaded !== true) {
this.playerElement = this.elementRef.nativeElement.querySelector('#video-element') this.playerElement = this.elementRef.nativeElement.querySelector('#video-element')
// If autoplay is true, we don't really need a poster
if (this.isAutoplay() === false) {
this.playerElement.poster = this.video.previewUrl
}
const videojsOptions = getVideojsOptions({ const videojsOptions = getVideojsOptions({
autoplay: this.isAutoplay(), autoplay: this.isAutoplay(),
inactivityTimeout: 4000, inactivityTimeout: 4000,
@ -350,7 +345,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid), videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid),
videoDuration: this.video.duration, videoDuration: this.video.duration,
enableHotkeys: true, enableHotkeys: true,
peertubeLink: false peertubeLink: false,
poster: this.video.previewUrl
}) })
this.videoPlayerLoaded = true this.videoPlayerLoaded = true

View File

@ -20,10 +20,12 @@ function getVideojsOptions (options: {
videoFiles: VideoFile[], videoFiles: VideoFile[],
enableHotkeys: boolean, enableHotkeys: boolean,
inactivityTimeout: number, inactivityTimeout: number,
peertubeLink: boolean peertubeLink: boolean,
poster: string
}) { }) {
const videojsOptions = { const videojsOptions = {
controls: true, controls: true,
poster: options.poster,
autoplay: options.autoplay, autoplay: options.autoplay,
inactivityTimeout: options.inactivityTimeout, inactivityTimeout: options.inactivityTimeout,
playbackRates: [ 0.5, 1, 1.5, 2 ], playbackRates: [ 0.5, 1, 1.5, 2 ],

View File

@ -212,6 +212,7 @@ class PeerTubePlugin extends Plugin {
this.alterInactivity() this.alterInactivity()
if (this.autoplay === true) { if (this.autoplay === true) {
this.player.posterImage.hide()
this.updateVideoFile(undefined, () => this.player.play()) this.updateVideoFile(undefined, () => this.player.play())
} else { } else {
// Proxify first play // Proxify first play

View File

@ -56,11 +56,11 @@ $setting-transition-easing: ease-out;
outline: 0; outline: 0;
font-size: 6em; font-size: 6em;
$big-play-width: 1.5em; $big-play-width: 1.2em;
$big-play-height: 1em; $big-play-height: 1.2em;
border: 0; border: 0;
border-radius: 0.3em; border-radius: 100%;
left: 50%; left: 50%;
top: 50%; top: 50%;
@ -77,14 +77,14 @@ $setting-transition-easing: ease-out;
} }
.vjs-icon-placeholder::before { .vjs-icon-placeholder::before {
transition: text-shadow 0.3s; transition: font-size 0.5s, opacity 0.5s;
} }
&:hover { &:hover {
opacity: 0.9; opacity: 0.8;
.vjs-icon-placeholder::before { .vjs-icon-placeholder::before {
text-shadow: 0 0 1px rgba(255, 255, 255, 0.8); font-size: 110%;
} }
} }
} }
@ -92,8 +92,28 @@ $setting-transition-easing: ease-out;
&.vjs-has-started .vjs-big-play-button { &.vjs-has-started .vjs-big-play-button {
display: block; display: block;
visibility: hidden; visibility: hidden;
opacity: 0;
transition: visibility 0.3s, opacity 0.3s; &, &::before {
opacity: 0;
transition: visibility 0.1s, opacity 0.1s;
}
}
&.vjs-has-started video {
background-color: #000;
animation: fade-black-on-play 0.5s linear;
@keyframes fade-black-on-play {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
} }
.vjs-control-bar, .vjs-control-bar,
@ -651,6 +671,10 @@ $setting-transition-easing: ease-out;
.vjs-menu-item { .vjs-menu-item {
&:hover {
background-color: rgba(255, 255, 255, 0.2);
}
&:first-child { &:first-child {
margin-top: 5px; margin-top: 5px;
} }

View File

@ -12,6 +12,7 @@ video {
html, body { html, body {
height: 100%; height: 100%;
margin: 0; margin: 0;
background-color: #000;
} }
.video-js.vjs-peertube-skin { .video-js.vjs-peertube-skin {

View File

@ -22,8 +22,6 @@ loadVideoInfo(videoId)
const videoContainerId = 'video-container' const videoContainerId = 'video-container'
const videoElement = document.getElementById(videoContainerId) as HTMLVideoElement const videoElement = document.getElementById(videoContainerId) as HTMLVideoElement
videoElement.poster = window.location.origin + videoInfo.previewPath
let autoplay = false let autoplay = false
try { try {
@ -41,7 +39,8 @@ loadVideoInfo(videoId)
videoFiles: videoInfo.files, videoFiles: videoInfo.files,
videoDuration: videoInfo.duration, videoDuration: videoInfo.duration,
enableHotkeys: true, enableHotkeys: true,
peertubeLink: true peertubeLink: true,
poster: window.location.origin + videoInfo.previewPath
}) })
videojs(videoContainerId, videojsOptions, function () { videojs(videoContainerId, videojsOptions, function () {
const player = this const player = this