aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone/videos')
-rw-r--r--client/src/standalone/videos/embed-api.ts4
-rw-r--r--client/src/standalone/videos/embed.ts12
-rw-r--r--client/src/standalone/videos/shared/player-html.ts3
-rw-r--r--client/src/standalone/videos/shared/player-manager-options.ts3
-rw-r--r--client/src/standalone/videos/shared/playlist-fetcher.ts5
-rw-r--r--client/src/standalone/videos/shared/playlist-tracker.ts3
-rw-r--r--client/src/standalone/videos/shared/video-fetcher.ts3
-rw-r--r--client/src/standalone/videos/test-embed.ts11
-rw-r--r--client/src/standalone/videos/tsconfig.json7
9 files changed, 33 insertions, 18 deletions
diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts
index 84d664654..2124b4711 100644
--- a/client/src/standalone/videos/embed-api.ts
+++ b/client/src/standalone/videos/embed-api.ts
@@ -1,6 +1,6 @@
1import './embed.scss' 1import './embed.scss'
2
3import * as Channel from 'jschannel' 2import * as Channel from 'jschannel'
3import { logger } from '../../root-helpers'
4import { PeerTubeResolution, PeerTubeTextTrack } from '../player/definitions' 4import { PeerTubeResolution, PeerTubeTextTrack } from '../player/definitions'
5import { PeerTubeEmbed } from './embed' 5import { PeerTubeEmbed } from './embed'
6 6
@@ -59,7 +59,7 @@ export class PeerTubeEmbedApi {
59 } 59 }
60 60
61 private setResolution (resolutionId: number) { 61 private setResolution (resolutionId: number) {
62 console.log('set resolution %d', resolutionId) 62 logger.info(`Set resolution ${resolutionId}`)
63 63
64 if (this.isWebtorrent()) { 64 if (this.isWebtorrent()) {
65 if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionPossible() === false) return 65 if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionPossible() === false) return
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index c15d4db17..5384ada1c 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -6,7 +6,7 @@ import { peertubeTranslate } from '../../../../shared/core-utils/i18n'
6import { HTMLServerConfig, LiveVideo, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement } from '../../../../shared/models' 6import { HTMLServerConfig, LiveVideo, ResultList, VideoDetails, VideoPlaylist, VideoPlaylistElement } from '../../../../shared/models'
7import { PeertubePlayerManager } from '../../assets/player' 7import { PeertubePlayerManager } from '../../assets/player'
8import { TranslationsManager } from '../../assets/player/translations-manager' 8import { TranslationsManager } from '../../assets/player/translations-manager'
9import { getParamString } from '../../root-helpers' 9import { getParamString, logger } from '../../root-helpers'
10import { PeerTubeEmbedApi } from './embed-api' 10import { PeerTubeEmbedApi } from './embed-api'
11import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, VideoFetcher } from './shared' 11import { AuthHTTP, LiveManager, PeerTubePlugin, PlayerManagerOptions, PlaylistFetcher, PlaylistTracker, VideoFetcher } from './shared'
12import { PlayerHTML } from './shared/player-html' 12import { PlayerHTML } from './shared/player-html'
@@ -31,6 +31,8 @@ export class PeerTubeEmbed {
31 private playlistTracker: PlaylistTracker 31 private playlistTracker: PlaylistTracker
32 32
33 constructor (videoWrapperId: string) { 33 constructor (videoWrapperId: string) {
34 logger.registerServerSending(window.location.origin)
35
34 this.http = new AuthHTTP() 36 this.http = new AuthHTTP()
35 37
36 this.videoFetcher = new VideoFetcher(this.http) 38 this.videoFetcher = new VideoFetcher(this.http)
@@ -43,7 +45,7 @@ export class PeerTubeEmbed {
43 try { 45 try {
44 this.config = JSON.parse(window['PeerTubeServerConfig']) 46 this.config = JSON.parse(window['PeerTubeServerConfig'])
45 } catch (err) { 47 } catch (err) {
46 console.error('Cannot parse HTML config.', err) 48 logger.error('Cannot parse HTML config.', err)
47 } 49 }
48 } 50 }
49 51
@@ -125,7 +127,7 @@ export class PeerTubeEmbed {
125 async playNextPlaylistVideo () { 127 async playNextPlaylistVideo () {
126 const next = this.playlistTracker.getNextPlaylistElement() 128 const next = this.playlistTracker.getNextPlaylistElement()
127 if (!next) { 129 if (!next) {
128 console.log('Next element not found in playlist.') 130 logger.info('Next element not found in playlist.')
129 return 131 return
130 } 132 }
131 133
@@ -137,7 +139,7 @@ export class PeerTubeEmbed {
137 async playPreviousPlaylistVideo () { 139 async playPreviousPlaylistVideo () {
138 const previous = this.playlistTracker.getPreviousPlaylistElement() 140 const previous = this.playlistTracker.getPreviousPlaylistElement()
139 if (!previous) { 141 if (!previous) {
140 console.log('Previous element not found in playlist.') 142 logger.info('Previous element not found in playlist.')
141 return 143 return
142 } 144 }
143 145
@@ -343,5 +345,5 @@ PeerTubeEmbed.main()
343 .catch(err => { 345 .catch(err => {
344 (window as any).displayIncompatibleBrowser() 346 (window as any).displayIncompatibleBrowser()
345 347
346 console.error('Cannot init embed.', err) 348 logger.error('Cannot init embed.', err)
347 }) 349 })
diff --git a/client/src/standalone/videos/shared/player-html.ts b/client/src/standalone/videos/shared/player-html.ts
index eb6324ac7..61231d2cb 100644
--- a/client/src/standalone/videos/shared/player-html.ts
+++ b/client/src/standalone/videos/shared/player-html.ts
@@ -1,5 +1,6 @@
1import { peertubeTranslate } from '../../../../../shared/core-utils/i18n' 1import { peertubeTranslate } from '../../../../../shared/core-utils/i18n'
2import { VideoDetails } from '../../../../../shared/models' 2import { VideoDetails } from '../../../../../shared/models'
3import { logger } from '../../../root-helpers'
3import { Translations } from './translations' 4import { Translations } from './translations'
4 5
5export class PlayerHTML { 6export class PlayerHTML {
@@ -29,7 +30,7 @@ export class PlayerHTML {
29 } 30 }
30 31
31 displayError (text: string, translations: Translations) { 32 displayError (text: string, translations: Translations) {
32 console.error(text) 33 logger.error(text)
33 34
34 // Remove video element 35 // Remove video element
35 if (this.playerElement) { 36 if (this.playerElement) {
diff --git a/client/src/standalone/videos/shared/player-manager-options.ts b/client/src/standalone/videos/shared/player-manager-options.ts
index f3bd46a69..2eeb5ecac 100644
--- a/client/src/standalone/videos/shared/player-manager-options.ts
+++ b/client/src/standalone/videos/shared/player-manager-options.ts
@@ -14,6 +14,7 @@ import {
14 getParamString, 14 getParamString,
15 getParamToggle, 15 getParamToggle,
16 isP2PEnabled, 16 isP2PEnabled,
17 logger,
17 peertubeLocalStorage, 18 peertubeLocalStorage,
18 UserLocalStorageKeys 19 UserLocalStorageKeys
19} from '../../../root-helpers' 20} from '../../../root-helpers'
@@ -137,7 +138,7 @@ export class PlayerManagerOptions {
137 else this.mode = 'webtorrent' 138 else this.mode = 'webtorrent'
138 } 139 }
139 } catch (err) { 140 } catch (err) {
140 console.error('Cannot get params from URL.', err) 141 logger.error('Cannot get params from URL.', err)
141 } 142 }
142 } 143 }
143 144
diff --git a/client/src/standalone/videos/shared/playlist-fetcher.ts b/client/src/standalone/videos/shared/playlist-fetcher.ts
index a7e72c177..713d82e3a 100644
--- a/client/src/standalone/videos/shared/playlist-fetcher.ts
+++ b/client/src/standalone/videos/shared/playlist-fetcher.ts
@@ -1,4 +1,5 @@
1import { HttpStatusCode, ResultList, VideoPlaylistElement } from '../../../../../shared/models' 1import { HttpStatusCode, ResultList, VideoPlaylistElement } from '../../../../../shared/models'
2import { logger } from '../../../root-helpers'
2import { AuthHTTP } from './auth-http' 3import { AuthHTTP } from './auth-http'
3 4
4export class PlaylistFetcher { 5export class PlaylistFetcher {
@@ -18,7 +19,7 @@ export class PlaylistFetcher {
18 playlistResponse = await playlistPromise 19 playlistResponse = await playlistPromise
19 isResponseOk = playlistResponse.status === HttpStatusCode.OK_200 20 isResponseOk = playlistResponse.status === HttpStatusCode.OK_200
20 } catch (err) { 21 } catch (err) {
21 console.error(err) 22 logger.error(err)
22 isResponseOk = false 23 isResponseOk = false
23 } 24 }
24 25
@@ -49,7 +50,7 @@ export class PlaylistFetcher {
49 } 50 }
50 51
51 if (i === 10) { 52 if (i === 10) {
52 console.error('Cannot fetch all playlists elements, there are too many!') 53 logger.error('Cannot fetch all playlists elements, there are too many!')
53 } 54 }
54 55
55 return elements 56 return elements
diff --git a/client/src/standalone/videos/shared/playlist-tracker.ts b/client/src/standalone/videos/shared/playlist-tracker.ts
index 75d10b4e2..9ea4be83f 100644
--- a/client/src/standalone/videos/shared/playlist-tracker.ts
+++ b/client/src/standalone/videos/shared/playlist-tracker.ts
@@ -1,4 +1,5 @@
1import { VideoPlaylist, VideoPlaylistElement } from '../../../../../shared/models' 1import { VideoPlaylist, VideoPlaylistElement } from '../../../../../shared/models'
2import { logger } from '../../../root-helpers'
2 3
3export class PlaylistTracker { 4export class PlaylistTracker {
4 private currentPlaylistElement: VideoPlaylistElement 5 private currentPlaylistElement: VideoPlaylistElement
@@ -68,7 +69,7 @@ export class PlaylistTracker {
68 setPosition (position: number) { 69 setPosition (position: number) {
69 this.currentPlaylistElement = this.playlistElements.find(e => e.position === position) 70 this.currentPlaylistElement = this.playlistElements.find(e => e.position === position)
70 if (!this.currentPlaylistElement || !this.currentPlaylistElement.video) { 71 if (!this.currentPlaylistElement || !this.currentPlaylistElement.video) {
71 console.error('Current playlist element is not valid.', this.currentPlaylistElement) 72 logger.error('Current playlist element is not valid.', this.currentPlaylistElement)
72 this.currentPlaylistElement = this.getNextPlaylistElement() 73 this.currentPlaylistElement = this.getNextPlaylistElement()
73 } 74 }
74 75
diff --git a/client/src/standalone/videos/shared/video-fetcher.ts b/client/src/standalone/videos/shared/video-fetcher.ts
index e78d38536..b42d622f9 100644
--- a/client/src/standalone/videos/shared/video-fetcher.ts
+++ b/client/src/standalone/videos/shared/video-fetcher.ts
@@ -1,4 +1,5 @@
1import { HttpStatusCode, LiveVideo, VideoDetails } from '../../../../../shared/models' 1import { HttpStatusCode, LiveVideo, VideoDetails } from '../../../../../shared/models'
2import { logger } from '../../../root-helpers'
2import { AuthHTTP } from './auth-http' 3import { AuthHTTP } from './auth-http'
3 4
4export class VideoFetcher { 5export class VideoFetcher {
@@ -17,7 +18,7 @@ export class VideoFetcher {
17 videoResponse = await videoPromise 18 videoResponse = await videoPromise
18 isResponseOk = videoResponse.status === HttpStatusCode.OK_200 19 isResponseOk = videoResponse.status === HttpStatusCode.OK_200
19 } catch (err) { 20 } catch (err) {
20 console.error(err) 21 logger.error(err)
21 22
22 isResponseOk = false 23 isResponseOk = false
23 } 24 }
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index 18c338a2d..ab5262902 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -1,6 +1,7 @@
1import './test-embed.scss' 1import './test-embed.scss'
2import { PeerTubeResolution, PlayerEventType } from '../player/definitions' 2import { PeerTubeResolution, PlayerEventType } from '../player/definitions'
3import { PeerTubePlayer } from '../player/player' 3import { PeerTubePlayer } from '../player/player'
4import { logger } from '../../root-helpers'
4 5
5window.addEventListener('load', async () => { 6window.addEventListener('load', async () => {
6 const urlParts = window.location.href.split('/') 7 const urlParts = window.location.href.split('/')
@@ -20,14 +21,14 @@ window.addEventListener('load', async () => {
20 const mainElement = document.querySelector('#host') 21 const mainElement = document.querySelector('#host')
21 mainElement.appendChild(iframe) 22 mainElement.appendChild(iframe)
22 23
23 console.log('Document finished loading.') 24 logger.info('Document finished loading.')
24 const player = new PeerTubePlayer(document.querySelector('iframe')) 25 const player = new PeerTubePlayer(document.querySelector('iframe'))
25 26
26 window['player'] = player 27 window['player'] = player
27 28
28 console.log('Awaiting player ready...') 29 logger.info('Awaiting player ready...')
29 await player.ready 30 await player.ready
30 console.log('Player is ready.') 31 logger.info('Player is ready.')
31 32
32 const monitoredEvents = [ 33 const monitoredEvents = [
33 'pause', 34 'pause',
@@ -37,8 +38,8 @@ window.addEventListener('load', async () => {
37 ] 38 ]
38 39
39 monitoredEvents.forEach(e => { 40 monitoredEvents.forEach(e => {
40 player.addEventListener(e as PlayerEventType, (param) => console.log(`PLAYER: event '${e}' received`, param)) 41 player.addEventListener(e as PlayerEventType, (param) => logger.info(`PLAYER: event '${e}' received`, { param }))
41 console.log(`PLAYER: now listening for event '${e}'`) 42 logger.info(`PLAYER: now listening for event '${e}'`)
42 43
43 player.getCurrentPosition() 44 player.getCurrentPosition()
44 .then(position => { 45 .then(position => {
diff --git a/client/src/standalone/videos/tsconfig.json b/client/src/standalone/videos/tsconfig.json
new file mode 100644
index 000000000..e0cab7ca3
--- /dev/null
+++ b/client/src/standalone/videos/tsconfig.json
@@ -0,0 +1,7 @@
1{
2 "extends": "../../../tsconfig.json",
3 "include": [
4 "src/standalone/videos/embed.ts",
5 "src/standalone/videos/test-embed.ts"
6 ]
7}