@@ -4,17 +4,17 @@ import {HALEndpointService} from '../../../../../core/shared/hal-endpoint.servic
44import { Router } from '@angular/router' ;
55import { ConfigurationDataService } from '../../../../../core/data/configuration-data.service' ;
66import { getFirstCompletedRemoteData , getFirstSucceededRemoteData } from '../../../../../core/shared/operators' ;
7- import { BitstreamDataService } from " ../../../../../core/data/bitstream-data.service" ;
8- import { Bitstream } from " ../../../../../core/shared/bitstream.model" ;
9- import { RemoteData } from " ../../../../../core/data/remote-data" ;
10- import { followLink } from " ../../../../../shared/utils/follow-link-config.model" ;
11- import { fromEvent , merge , Observable , of } from " rxjs" ;
12- import { FileService } from " ../../../../../core/shared/file.service" ;
13- import { distinctUntilChanged , switchMap , take } from " rxjs/operators" ;
14- import { FeatureID } from " ../../../../../core/data/feature-authorization/feature-id" ;
15- import { hasValue } from " ../../../../../shared/empty.util" ;
16- import { AuthorizationDataService } from " ../../../../../core/data/feature-authorization/authorization-data.service" ;
17- import { AuthService } from " ../../../../../core/auth/auth.service" ;
7+ import { BitstreamDataService } from ' ../../../../../core/data/bitstream-data.service' ;
8+ import { Bitstream } from ' ../../../../../core/shared/bitstream.model' ;
9+ import { RemoteData } from ' ../../../../../core/data/remote-data' ;
10+ import { followLink } from ' ../../../../../shared/utils/follow-link-config.model' ;
11+ import { fromEvent , merge , Observable , of } from ' rxjs' ;
12+ import { FileService } from ' ../../../../../core/shared/file.service' ;
13+ import { distinctUntilChanged , switchMap , take } from ' rxjs/operators' ;
14+ import { FeatureID } from ' ../../../../../core/data/feature-authorization/feature-id' ;
15+ import { hasValue } from ' ../../../../../shared/empty.util' ;
16+ import { AuthorizationDataService } from ' ../../../../../core/data/feature-authorization/authorization-data.service' ;
17+ import { AuthService } from ' ../../../../../core/auth/auth.service' ;
1818
1919const allowedPreviewFormats = [ 'text/plain' , 'text/html' , 'application/zip' , 'application/x-tar' ] ;
2020@Component ( {
@@ -29,10 +29,14 @@ export class FileDescriptionComponent implements OnInit {
2929 @Input ( )
3030 fileInput : MetadataBitstream ;
3131
32+ @ViewChild ( 'videoPreview' ) videoElement : ElementRef ;
33+
3234 emailToContact : string ;
3335 content_url$ : Observable < string > ;
3436 content_url : string ;
3537 thumbnail_url$ : Observable < string > ;
38+ handlers_added = false ;
39+ playPromise : Promise < void > ;
3640
3741 constructor ( protected halService : HALEndpointService ,
3842 private router : Router ,
@@ -50,14 +54,14 @@ export class FileDescriptionComponent implements OnInit {
5054 } ) ;
5155 this . content_url$ = this . bitstreamService . findById ( this . fileInput . id , true , false , followLink ( 'thumbnail' ) )
5256 . pipe ( getFirstCompletedRemoteData ( ) ,
53- switchMap ( ( remoteData : RemoteData < Bitstream > ) => {
57+ switchMap ( ( remoteData : RemoteData < Bitstream > ) => {
5458 if ( remoteData . hasSucceeded ) {
5559 this . thumbnail_url$ = remoteData . payload ?. thumbnail . pipe (
5660 switchMap ( ( thumbnailRD : RemoteData < Bitstream > ) => {
5761 if ( thumbnailRD . hasSucceeded ) {
5862 return this . buildUrl ( thumbnailRD . payload ?. _links . content . href ) ;
5963 } else {
60- return of ( "" ) ;
64+ return of ( '' ) ;
6165 }
6266 } ) ,
6367 ) ;
@@ -70,7 +74,6 @@ export class FileDescriptionComponent implements OnInit {
7074 } ) ;
7175 }
7276
73- @ViewChild ( 'videoPreview' ) videoElement : ElementRef ;
7477 ngAfterViewInit ( ) {
7578 const video = this . videoElement ?. nativeElement ;
7679
@@ -82,7 +85,7 @@ export class FileDescriptionComponent implements OnInit {
8285 this . auth . isAuthenticated ( ) . pipe (
8386 switchMap ( ( isLoggedIn ) => {
8487 if ( isLoggedIn ) {
85- return this . authDataService . isAuthorized ( FeatureID . CanDownload , this . content_url . replace ( '/content' , '' ) )
88+ return this . authDataService . isAuthorized ( FeatureID . CanDownload , this . content_url . replace ( '/content' , '' ) ) ;
8689 } else {
8790 return of ( false ) ;
8891 }
@@ -100,8 +103,6 @@ export class FileDescriptionComponent implements OnInit {
100103 }
101104 }
102105
103- handlers_added = false ;
104-
105106 private add_short_lived_token_handling_to_video_playback ( video : HTMLVideoElement ) {
106107 if ( this . handlers_added ) {
107108 return ;
@@ -129,9 +130,6 @@ export class FileDescriptionComponent implements OnInit {
129130
130131 }
131132
132-
133- playPromise ;
134-
135133 private resetSource ( currentTime ?) {
136134 const video = this . videoElement ?. nativeElement ;
137135 //console.log("networkState in resetSource", video.networkState);
@@ -141,7 +139,9 @@ export class FileDescriptionComponent implements OnInit {
141139 // don't want to see The play() request was interrupted by...
142140 // https://developer.chrome.com/blog/play-request-was-interrupted
143141 this . updateSource ( video , currentTime ) ;
144- } ) . catch ( _ => { } ) ;
142+ } ) . catch ( _ => {
143+ //do nothing
144+ } ) ;
145145 } else {
146146 this . updateSource ( video , currentTime ) ;
147147 }
@@ -151,7 +151,7 @@ export class FileDescriptionComponent implements OnInit {
151151 //console.log("Updating the src");
152152 this . buildUrl ( this . content_url ) . subscribe ( result => {
153153 video . src = result ;
154- if ( currentTime ) {
154+ if ( currentTime ) {
155155 video . currentTime = currentTime ;
156156 }
157157 this . playPromise = video . play ( ) ;
0 commit comments