aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/test-embed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-10 18:02:30 +0200
committerChocobozzz <me@florianbigard.com>2018-07-10 18:02:40 +0200
commit902aa3a099638b2198c24c076c61577a8435277b (patch)
treeaa53daa4f071b7f8f2985e61a16c0ded2fcce7cd /client/src/standalone/videos/test-embed.ts
parent999417328bde0e60cd59318fc1c18672356254ce (diff)
downloadPeerTube-902aa3a099638b2198c24c076c61577a8435277b.tar.gz
PeerTube-902aa3a099638b2198c24c076c61577a8435277b.tar.zst
PeerTube-902aa3a099638b2198c24c076c61577a8435277b.zip
Fix player lint
Diffstat (limited to 'client/src/standalone/videos/test-embed.ts')
-rw-r--r--client/src/standalone/videos/test-embed.ts32
1 files changed, 15 insertions, 17 deletions
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index 721514488..c0181ed28 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -1,49 +1,47 @@
1import './test-embed.scss' 1import './test-embed.scss'
2import { PeerTubePlayer } from '../player/player'; 2import { PeerTubePlayer } from '../player/player'
3import { PlayerEventType } from '../player/definitions'; 3import { PlayerEventType } from '../player/definitions'
4 4
5window.addEventListener('load', async () => { 5window.addEventListener('load', async () => {
6
7 const urlParts = window.location.href.split('/') 6 const urlParts = window.location.href.split('/')
8 const lastPart = urlParts[urlParts.length - 1] 7 const lastPart = urlParts[ urlParts.length - 1 ]
9 const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[0] 8 const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ]
10 9
11 let iframe = document.createElement('iframe') 10 let iframe = document.createElement('iframe')
12 iframe.src = `/videos/embed/${videoId}?autoplay=1&controls=0&api=1` 11 iframe.src = `/videos/embed/${videoId}?autoplay=1&controls=0&api=1`
13 let mainElement = document.querySelector('#host') 12 let mainElement = document.querySelector('#host')
14 mainElement.appendChild(iframe); 13 mainElement.appendChild(iframe)
15 14
16 console.log(`Document finished loading.`) 15 console.log(`Document finished loading.`)
17 let player = new PeerTubePlayer(document.querySelector('iframe')) 16 let player = new PeerTubePlayer(document.querySelector('iframe'))
18 17
19 window['player'] = player 18 window[ 'player' ] = player
20 19
21 console.log(`Awaiting player ready...`) 20 console.log(`Awaiting player ready...`)
22 await player.ready 21 await player.ready
23 console.log(`Player is ready.`) 22 console.log(`Player is ready.`)
24 23
25 let monitoredEvents = [ 24 let monitoredEvents = [
26 'pause', 'play', 25 'pause',
27 'playbackStatusUpdate', 26 'play',
27 'playbackStatusUpdate',
28 'playbackStatusChange' 28 'playbackStatusChange'
29 ] 29 ]
30 30
31 monitoredEvents.forEach(e => { 31 monitoredEvents.forEach(e => {
32 player.addEventListener(<PlayerEventType>e, () => console.log(`PLAYER: event '${e}' received`)) 32 player.addEventListener(e as PlayerEventType, () => console.log(`PLAYER: event '${e}' received`))
33 console.log(`PLAYER: now listening for event '${e}'`) 33 console.log(`PLAYER: now listening for event '${e}'`)
34 }) 34 })
35 35
36 let playbackRates = [] 36 let playbackRates: number[] = []
37 let activeRate = 1
38 let currentRate = await player.getPlaybackRate() 37 let currentRate = await player.getPlaybackRate()
39 38
40 let updateRates = async () => { 39 let updateRates = async () => {
41
42 let rateListEl = document.querySelector('#rate-list') 40 let rateListEl = document.querySelector('#rate-list')
43 rateListEl.innerHTML = '' 41 rateListEl.innerHTML = ''
44 42
45 playbackRates.forEach(rate => { 43 playbackRates.forEach(rate => {
46 if (currentRate == rate) { 44 if (currentRate === rate) {
47 let itemEl = document.createElement('strong') 45 let itemEl = document.createElement('strong')
48 itemEl.innerText = `${rate} (active)` 46 itemEl.innerText = `${rate} (active)`
49 itemEl.style.display = 'block' 47 itemEl.style.display = 'block'
@@ -93,6 +91,6 @@ window.addEventListener('load', async () => {
93 91
94 player.getResolutions().then( 92 player.getResolutions().then(
95 resolutions => updateResolutions(resolutions)) 93 resolutions => updateResolutions(resolutions))
96 player.addEventListener('resolutionUpdate', 94 player.addEventListener('resolutionUpdate',
97 resolutions => updateResolutions(resolutions)) 95 resolutions => updateResolutions(resolutions))
98}) \ No newline at end of file 96})