// Video source for test const sources = [ { src: 'https://livetv.canbroadcast.com:7443/media/2023/sah_damari/sah_damari_2023-26-09__20-00-27.mp4', type: 'video/mp4' }, { src: 'https://livetv.canbroadcast.com:7443/canlinow/sah_damari_2023-26-09__20-00-27.m3u8', type: 'application/x-mpegURL' } ] let index = 0 // Currently loaded video source sequence number var player = videojs('my-video', { fluid: true, responsive: true, width: 380, controls: true, preload: 'auto', autoplay: 'true', // The key to realize automatic video playback sources: sources[index] }) videojs.hook('beforeerror', (player, err) => { console.log('beforeerror', index, player.src(), err) // Video.js will trigger an err=null error immediately after switching / specifying the source. Filter it here if (err !== null) { player.src(sources[++index]) } // Clear the error to prevent the error event from throwing an error on the console return null }) // Other events and hooks that can observe progress // videojs.hook('error', (player, err) => { // console.log('error') // return err // }) // player.on('loadeddata', () => { // console.log('loadeddata') // }) // player. On('loadedmetadata', () => { // console.log('loadedmetadata') // }) // player.on('loadstart', () => { // console.log('loadstart') // })