<link href="https://vjs.zencdn.net/7.15.4/video-js.css" rel="stylesheet" /> <script src="https://vjs.zencdn.net/7.15.4/video.min.js"></script> <video width="300" height="150" id="my-video" class="video-js" poster="https://livetv.canbroadcast.com:7443/media/2022/ana_haber_bulteni/ana_haber_bulteni_2022-14-03__17-28-52.jpg"> </video> <script> // Video source for test const sources = [ { src: 'https://livetv.canbroadcast.com:7443/media/2022/ana_haber_bulteni/ana_haber_bulteni_2022-14-03__17-28-52.mp4', type: 'video/mp4' }, { src: 'https://livetv.canbroadcast.com:7443/canlinow/ana_haber_bulteni_2022-14-03__17-00-05.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') // }) </script> <img src="https://livetv.canbroadcast.com:7443/media/2022/ana_haber_bulteni/ana_haber_bulteni_2022-14-03__17-28-52.jpg" alt="Elif Sonzamancı ile Can Ana Haber Bülteni sizlerle... - 14.03.2022" width="50" height="60">