aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-14 17:16:32 +0100
committerChocobozzz <me@florianbigard.com>2018-02-14 17:16:32 +0100
commit8cac1b6446a97b16387c9590ce5c799a79a759fa (patch)
tree6ef95c108b9323e47d1b979a01934398b0752dac /client/src/app
parenta16aee73db627908dc83eb5c29b213ce8d1fab39 (diff)
downloadPeerTube-8cac1b6446a97b16387c9590ce5c799a79a759fa.tar.gz
PeerTube-8cac1b6446a97b16387c9590ce5c799a79a759fa.tar.zst
PeerTube-8cac1b6446a97b16387c9590ce5c799a79a759fa.zip
Move adding a video view videojs peertube plugin
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/shared/video/infinite-scroller.directive.ts3
-rw-r--r--client/src/app/shared/video/video.service.ts6
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts20
3 files changed, 11 insertions, 18 deletions
diff --git a/client/src/app/shared/video/infinite-scroller.directive.ts b/client/src/app/shared/video/infinite-scroller.directive.ts
index 43e014cbd..52d8b2b37 100644
--- a/client/src/app/shared/video/infinite-scroller.directive.ts
+++ b/client/src/app/shared/video/infinite-scroller.directive.ts
@@ -1,5 +1,8 @@
1import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core' 1import { Directive, EventEmitter, Input, OnInit, Output } from '@angular/core'
2import 'rxjs/add/operator/debounceTime'
2import 'rxjs/add/operator/distinct' 3import 'rxjs/add/operator/distinct'
4import 'rxjs/add/operator/filter'
5import 'rxjs/add/operator/map'
3import 'rxjs/add/operator/startWith' 6import 'rxjs/add/operator/startWith'
4import { fromEvent } from 'rxjs/observable/fromEvent' 7import { fromEvent } from 'rxjs/observable/fromEvent'
5 8
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index d4f5e258f..01d32176b 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -29,6 +29,10 @@ export class VideoService {
29 private restService: RestService 29 private restService: RestService
30 ) {} 30 ) {}
31 31
32 getVideoViewUrl (uuid: string) {
33 return VideoService.BASE_VIDEO_URL + uuid + '/views'
34 }
35
32 getVideo (uuid: string): Observable<VideoDetails> { 36 getVideo (uuid: string): Observable<VideoDetails> {
33 return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid) 37 return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + uuid)
34 .map(videoHash => new VideoDetails(videoHash)) 38 .map(videoHash => new VideoDetails(videoHash))
@@ -36,7 +40,7 @@ export class VideoService {
36 } 40 }
37 41
38 viewVideo (uuid: string): Observable<VideoDetails> { 42 viewVideo (uuid: string): Observable<VideoDetails> {
39 return this.authHttp.post(VideoService.BASE_VIDEO_URL + uuid + '/views', {}) 43 return this.authHttp.post(this.getVideoViewUrl(uuid), {})
40 .map(this.restExtractor.extractDataBool) 44 .map(this.restExtractor.extractDataBool)
41 .catch(this.restExtractor.handleError) 45 .catch(this.restExtractor.handleError)
42 } 46 }
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 8330aba15..b7779ae9a 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -329,7 +329,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
329 peertube: { 329 peertube: {
330 videoFiles: this.video.files, 330 videoFiles: this.video.files,
331 playerElement: this.playerElement, 331 playerElement: this.playerElement,
332 peerTubeLink: false 332 peerTubeLink: false,
333 videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid)
333 }, 334 },
334 hotkeys: { 335 hotkeys: {
335 enableVolumeScroll: false 336 enableVolumeScroll: false
@@ -349,7 +350,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
349 }) 350 })
350 }) 351 })
351 } else { 352 } else {
352 this.player.peertube().setVideoFiles(this.video.files) 353 this.player.peertube().setVideoFiles(this.video.files, this.videoService.getVideoViewUrl(this.video.uuid))
353 } 354 }
354 355
355 this.setVideoDescriptionHTML() 356 this.setVideoDescriptionHTML()
@@ -357,8 +358,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
357 358
358 this.setOpenGraphTags() 359 this.setOpenGraphTags()
359 this.checkUserRating() 360 this.checkUserRating()
360
361 this.prepareViewAdd()
362 } 361 }
363 ) 362 )
364 } 363 }
@@ -431,19 +430,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
431 this.metaService.setTag('url', window.location.href) 430 this.metaService.setTag('url', window.location.href)
432 } 431 }
433 432
434 private prepareViewAdd () {
435 // After 30 seconds (or 3/4 of the video), increment add a view
436 let viewTimeoutSeconds = 30
437 if (this.video.duration < viewTimeoutSeconds) viewTimeoutSeconds = (this.video.duration * 3) / 4
438
439 setTimeout(() => {
440 this.videoService
441 .viewVideo(this.video.uuid)
442 .subscribe()
443
444 }, viewTimeoutSeconds * 1000)
445 }
446
447 private isAutoplay () { 433 private isAutoplay () {
448 // True by default 434 // True by default
449 if (!this.user) return true 435 if (!this.user) return true