File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -77,17 +77,22 @@ export default class TV {
7777 * Pause and play the video
7878 * @public
7979 */
80- toggleVideo ( ) {
81- // Change playing state
82- this . isPlaying = ! this . isPlaying ;
83-
84- // Toggle play and pause
85- if ( this . isPlaying ) {
86- this . video . play ( ) ;
87- this . audio . start ( 0 , this . video . currentTime ) ;
80+ async toggleVideo ( ) {
81+ // Try to play the video if it's paused
82+ if ( ! this . isPlaying ) {
83+ try {
84+ await this . video . play ( ) . then ( async ( ) => {
85+ this . audio . start ( 0 , this . video . currentTime ) ;
86+ this . isPlaying = true ;
87+ } ) ;
88+ } catch ( error ) {
89+ this . isPlaying = false ;
90+ }
8891 } else {
92+ // Pause the video if it's playing
8993 this . video . pause ( ) ;
9094 this . audio . stop ( ) ;
95+ this . isPlaying = false ;
9196 }
9297 }
9398
You can’t perform that action at this time.
0 commit comments