]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/video/video-details.model.ts
Use HLS by default if enabled
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / video / video-details.model.ts
1 import { UserRight, VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
2 import { AuthUser } from '../../core'
3 import { Video } from '../../shared/video/video.model'
4 import { Account } from '@app/shared/account/account.model'
5 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
6 import { VideoStreamingPlaylist } from '../../../../../shared/models/videos/video-streaming-playlist.model'
7 import { VideoStreamingPlaylistType } from '../../../../../shared/models/videos/video-streaming-playlist.type'
8
9 export class VideoDetails extends Video implements VideoDetailsServerModel {
10 descriptionPath: string
11 support: string
12 channel: VideoChannel
13 tags: string[]
14 files: VideoFile[]
15 account: Account
16 commentsEnabled: boolean
17 downloadEnabled: boolean
18
19 waitTranscoding: boolean
20 state: VideoConstant<VideoState>
21
22 likesPercent: number
23 dislikesPercent: number
24
25 trackerUrls: string[]
26
27 streamingPlaylists: VideoStreamingPlaylist[]
28
29 constructor (hash: VideoDetailsServerModel, translations = {}) {
30 super(hash, translations)
31
32 this.descriptionPath = hash.descriptionPath
33 this.files = hash.files
34 this.channel = new VideoChannel(hash.channel)
35 this.account = new Account(hash.account)
36 this.tags = hash.tags
37 this.support = hash.support
38 this.commentsEnabled = hash.commentsEnabled
39 this.downloadEnabled = hash.downloadEnabled
40
41 this.trackerUrls = hash.trackerUrls
42 this.streamingPlaylists = hash.streamingPlaylists
43
44 this.buildLikeAndDislikePercents()
45 }
46
47 buildLikeAndDislikePercents () {
48 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
49 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
50 }
51
52 getHlsPlaylist () {
53 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
54 }
55
56 hasHlsPlaylist () {
57 return !!this.getHlsPlaylist()
58 }
59 }