aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/src/assets/player/video-renderer.ts6
-rw-r--r--server/tests/cli/create-transcoding-job.ts15
2 files changed, 18 insertions, 3 deletions
diff --git a/client/src/assets/player/video-renderer.ts b/client/src/assets/player/video-renderer.ts
index 4affb43cf..4b54b661a 100644
--- a/client/src/assets/player/video-renderer.ts
+++ b/client/src/assets/player/video-renderer.ts
@@ -50,7 +50,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
50 50
51 return fallbackToMediaSource() 51 return fallbackToMediaSource()
52 }) 52 })
53 preparedElem.addEventListener('loadstart', onLoadStart) 53 preparedElem.addEventListener('canplay', onLoadStart)
54 return videostream(file, preparedElem) 54 return videostream(file, preparedElem)
55 } 55 }
56 56
@@ -66,7 +66,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
66 66
67 return callback(err) 67 return callback(err)
68 }) 68 })
69 preparedElem.addEventListener('loadstart', onLoadStart) 69 preparedElem.addEventListener('canplay', onLoadStart)
70 70
71 const wrapper = new MediaElementWrapper(preparedElem) 71 const wrapper = new MediaElementWrapper(preparedElem)
72 const writable = wrapper.createWriteStream(codecs) 72 const writable = wrapper.createWriteStream(codecs)
@@ -95,7 +95,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca
95 } 95 }
96 96
97 function onLoadStart () { 97 function onLoadStart () {
98 preparedElem.removeEventListener('loadstart', onLoadStart) 98 preparedElem.removeEventListener('canplay', onLoadStart)
99 if (opts.autoplay) preparedElem.play() 99 if (opts.autoplay) preparedElem.play()
100 100
101 callback(null, renderer) 101 callback(null, renderer)
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index c2214d285..557dd8af9 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -72,12 +72,27 @@ describe('Test create transcoding jobs', function () {
72 const videos = res.body.data 72 const videos = res.body.data
73 expect(videos).to.have.lengthOf(2) 73 expect(videos).to.have.lengthOf(2)
74 74
75 let infoHashes: { [ id: number ]: string }
76
75 for (const video of videos) { 77 for (const video of videos) {
76 const res2 = await getVideo(server.url, video.uuid) 78 const res2 = await getVideo(server.url, video.uuid)
77 const videoDetail: VideoDetails = res2.body 79 const videoDetail: VideoDetails = res2.body
78 80
79 if (video.uuid === video2UUID) { 81 if (video.uuid === video2UUID) {
80 expect(videoDetail.files).to.have.lengthOf(4) 82 expect(videoDetail.files).to.have.lengthOf(4)
83
84 if (!infoHashes) {
85 infoHashes = {}
86
87 for (const file of videoDetail.files) {
88 infoHashes[file.resolution.id.toString()] = file.magnetUri
89 }
90 } else {
91 for (const resolution of Object.keys(infoHashes)) {
92 const file = videoDetail.files.find(f => f.resolution.id.toString() === resolution)
93 expect(file.magnetUri).to.equal(infoHashes[resolution])
94 }
95 }
81 } else { 96 } else {
82 expect(videoDetail.files).to.have.lengthOf(1) 97 expect(videoDetail.files).to.have.lengthOf(1)
83 } 98 }