Sometimes we need to call parsed broadcast interfaces, the use of video playback, but after pausing started, the live video will not automatically refresh, but continue to start playing from the point in time before it was suspended.
Here is my solution code, see my brothers the following:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> 6 <title></title> 7 <script src="js/mui.min.js"></script> 8 <link href="css/mui.min.css" rel="stylesheet"/> 9 <script type="text/javascript" charset="utf-8"> 10 mui.init(); 11 </script> 12 </head> 13 <body> 14 <div class="mui-content" style="background-color: #000000;"> 15 <video ontimeupdate="myFunction()" width="100%" height="auto" id="videoPlay1" poster="/hyData/weixinPages/images/video-img.png" 16 controls=controls 17 x5-playsinline="" 18 webkit-playsinline="true" 19 playsinline="true"> 20 <source src="http://tx.hls.huya.com/huyalive/93779849-93779849-402781384478818304-142748044-10057-A-0-1.m3u8?wsSecret=c35b2cf6ea8d4e423f1f4337bad6f3b6&wsTime=4ce2430d"> 21 </video> 22 </div> 23 </body> 24 <script> 25 In Flag = to false ; 26 is var VID = document.getElementById ( " videoPlay1 " ); 27 the console.log (VID); 28 function myFunction () { 29 // get the current playing time of 30 // the console.log (vid.currentTime) ; 31 is // to false true player clicks the click pause 32 // the console.log (vid.paused); 33 is IF (vid.paused) { 34 is the console.log ( " have suspended " ); 35 / * Here are some particularly complex function * / 36 var T2 = the window.setInterval ( function () { 37 [ IF ( ! Vid.paused) { 38 is vid.load (); 39 vid.play (); 40 window.clearInterval (T2); // removing the timer 41 is Console .log ( " restart playback video " ); 42 is } 43 is the console.log ( " is performing scheduled task " ); 44 }, 100 ); 45 } 46 }; 47 </script> 48 </html>