Question: After the dynamic creation of multiple video instance, after switching to another page in the switch back, can not play, the console newspaper warned id is occupied!
Ideas: Destruction video instance created in the life cycle of beforeDestroy function.
Code:
beforeDestroy () { // (third step) to get the video before destroying Examples for (the let I = 0; I < the this .playlist.length; I ++ ) { the this .playlist [I] .Dispose (); // ( a fourth step) Dispose () is the official destructor } }, Mounted () { the setTimeout (_ => { the let lang = the this .videolist.pageData.length // (First step) this is the address of the array of the plurality of video length for (the let I = 0; I <lang; I ++ ) { var player = videojs ( "My-Video" + I, { // event played textTrackDisplay: to false , posterImage:to true , ErrorDisplay: to false , controlBar: to true , HLS: { withCredentials: to true } }, function () { // this.play () // cancel AutoPlay }) the this .playlist.push (Player) // (second step) palylist empty array is defined, a plurality of video storage instances } }, 1000 ); },
Continued on blog post "Play m3u8 format in the video project vue"
Blog address: https: //www.cnblogs.com/cb1490838281/p/12331262.html