Add transition on play/loading player
authorChocobozzz <me@florianbigard.com>
Wed, 20 Dec 2017 10:05:10 +0000 (11:05 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 20 Dec 2017 10:05:10 +0000 (11:05 +0100)
client/src/assets/player/peertube-videojs-plugin.ts
client/src/sass/video-js-custom.scss
server/lib/cache/videos-preview-cache.ts
server/models/video/video.ts

index 8c131c9e9db9888f0299188983bfb048309fa5b7..ca2b9a724929738e2f44f43c8c6c50b613bcede6 100644 (file)
@@ -263,7 +263,7 @@ const peertubePlugin = function (options: PeertubePluginOptions) {
     const isPaused = player.paused()
 
     // Hide bigPlayButton
-    if (!isPaused && this.player_.options_.bigPlayButton) {
+    if (!isPaused) {
       this.player_.bigPlayButton.hide()
     }
 
index b093bbdecfb898d75dcc55bbfcff2198a6c05cf9..72487499587ce11ffdb1697449a30f47786e3701 100644 (file)
@@ -39,6 +39,25 @@ $control-bar-height: 34px;
     background-color: transparent !important;
   }
 
+  &.vjs-has-started .vjs-big-play-button {
+    display: block;
+    visibility: hidden;
+    opacity: 0;
+    transition: visibility 0.5s, opacity 0.5s;
+  }
+
+  .vjs-loading-spinner {
+    display: block;
+    visibility: hidden;
+    opacity: 0;
+  }
+
+  &.vjs-waiting .vjs-loading-spinner {
+    visibility: visible;
+    opacity: 1;
+    transition: visibility 0.5s, opacity 0.5s;
+  }
+
   .vjs-control-bar,
   .vjs-big-play-button,
   .vjs-menu-button .vjs-menu-content {
@@ -308,6 +327,10 @@ $control-bar-height: 34px;
   }
 
   @media screen and (max-width: 550px) {
+    .vjs-big-play-button {
+      font-size: 6.5em;
+    }
+
     .vjs-webtorrent {
       padding: 0 !important;
 
@@ -318,6 +341,14 @@ $control-bar-height: 34px;
   }
 
   @media screen and (max-width: 300px) {
+    .vjs-dock-text {
+      font-size: 1.5em;
+    }
+
+    .vjs-big-play-button {
+      font-size: 5em;
+    }
+
     .vjs-volume-control {
       display: none !important;
     }
index c5bda8dd894e699471bfc50765db882f0c388555..28908b186498ae104bef05f4d4e28e4508d992f9 100644 (file)
@@ -33,7 +33,12 @@ class VideosPreviewCache {
     })
   }
 
-  getPreviewPath (key: string) {
+  async getPreviewPath (key: string) {
+    const video = await VideoModel.loadByUUID(key)
+    if (!video) return undefined
+
+    if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
+
     return new Promise<string>((res, rej) => {
       this.lru.get(key, (err, value) => {
         err ? rej(err) : res(value)
@@ -42,10 +47,10 @@ class VideosPreviewCache {
   }
 
   private async loadPreviews (key: string) {
-    const video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(key)
+    const video = await VideoModel.loadByUUID(key)
     if (!video) return undefined
 
-    if (video.isOwned()) return join(CONFIG.STORAGE.PREVIEWS_DIR, video.getPreviewName())
+    if (video.isOwned()) throw new Error('Cannot load preview of owned video.')
 
     const res = await this.saveRemotePreviewAndReturnPath(video)
 
index 97fdbc8effc4c48c075eaec93d5f537dea9caeac..8c49bc3afa3a492d4176b30cfdce2992da3349fc 100644 (file)
@@ -528,6 +528,18 @@ export class VideoModel extends Model<VideoModel> {
       .findById(id, options)
   }
 
+  static loadByUUID (uuid: string) {
+    const options = {
+      where: {
+        uuid
+      }
+    }
+
+    return VideoModel
+      .scope([ ScopeNames.WITH_FILES ])
+      .findOne(options)
+  }
+
   static loadByUUIDAndPopulateAccountAndServerAndTags (uuid: string) {
     const options = {
       order: [ [ 'Tags', 'name', 'ASC' ] ],