Before doing a project, one of the features is to view social stream posts. Many posts contain video, and there is a level of confusion after the video is played on the phone.
The solution at the time was to dynamically put the video into the IFRAME. In the future, if there are other solutions will be appended.
The video uses a ratio of 16:9.
Example:
Html:
<id= "Video" class= "Video-wrap"></Div >
Css:
. Video-wrap{background:#ddd;position:relative;Display:Block;Height:0;padding:0;Overflow:Hidden;Padding-bottom:56.25%;width:100%;Z-index:1;}. Video-wrap iframe{position:Absolute;Top:0; Left:0;width:100%;Height:100%;Border:0;Border:0;Z-index:2}}
Js:
varVideopost;//Video CovervarVIDEOSRC;//Video Addressvar videowrap = document.queryselector ("#video");//insert a video divvariframe = document.createelement (' iframe '); videowrap.innerhtml= ' '; Videowrap.appendchild (iframe); Iframe.src= ' javascript:void (function () {var script = document.createelement (\ ' script\ '); ' + ' script.innerhtml = "(function () {' + ' Document.open ();d ocument.domain=\ ' + document.domain + ' \ ';d ocument.close ();}) (); "; ' + ' document.write (" ; Iframe.setattribute ("allowFullScreen", "true");varv = ' <video webkit-playsinline= ' true "playsinline=" true "controls=" Controls "class=" video "preload=" None "poster=" ' +videopost+ ' "><source src=" ' +videosrc+ ' "type=" Video/mp4 "></video>"; Iframe.contentWindow.document.write (' <meta content= ' Text/html;charset=utf-8 "http-equiv=" Content-type "/><meta name=" viewport "content=" width= Device-width,initial-scale=1,maximum-scale=1,user-scalable=no "/><meta http-equiv=" X-UA-Compatible "content = "Ie=edge,chrome=1"/><meta http-equiv= "x-ua-compatible" content= "ie=10"/><style>*{padding:0; margin:0;}. Videowrap{background: #ddd;p Osition:relative;display:block;height:0;padding:0;overflow:hidden;padding-bottom : 56.25%;width:100%;}. Videowrap video{position:absolute;top:0;left:0;width:100%;height:100%;border:0;border:0;} </style><div class= "Videowrap" > ' +v+ ' </div> ');
Solve the problem of post-mobile video playback level confusion