JavaScript realizes video Carousel can _javascript skill in PC and mobile end

Source: Internet
Author: User
Recent customer requests to use JavaScript to implement video carousel:

Interested students can participate in the Open

The following write a program to achieve video carousel, PC end and mobile end can be realized,

But the mobile side, there is a little bug;
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "textml; Charset=utf-8 ">
<title>insert title here</title>

<p> Video Carousel 11</p>
<div id= "Container" ></div>

<p> Video Carousel 22</p>
</body>
<ml>

<script type= "Text/javascript" >
var index=0;
var arr = new Array ("71da9e4b6985a7b5951dd62ce7bb020d_7", "71da9e4b691a41961dcd6524593d39ee_7", " 71da9e4b69efa71be86d625508ec9feb_7 ");

var container = document.getElementById ("container");
function Printplayer (index) {
alert (arr.length);
if (index>arr.length-1) {
index=0;
}
Container.removeelement;
Container.innerhtml= "";
var vid=arr[index];
if (Navigator.userAgent.match (/IP (OD|HONE|AD)/i)) {
var video = document.createelement ("video");
VIDEO.SRC = "http://v.polyv.net/uc/video/getMp4?vid=" +vid;
Video.onended=s2j_onplayover;
Video.addeventlistener (' ended ', J2s_onplayover, false);
Video.autoplay= "true";
Video.controls= "Controls"
Container.appendchild (video);
}else{

var swf= "http://player.polyv.net/player_polyv_20130926a.swf?vid=" +vid;

container.innerhtml = "<object width= ' height= ' 375 ' ><param name=movie" "Value=" +vid+ ><PARAM ' allowScriptAccess ' value= ' always ' > '
+ "<param name= ' allowfullscreen ' value= ' true '/>"
+ "<embed src= '" +swf+ "' width= ' height= ' 375 ' type= ' application/x-shockwave-flash '" allowscriptaccess= ' "Always ' Allowfullscreen= ' true '/></embed> '
+ "</OBJECT>";
<!--container.innerhtml = "<OBJECT>" +swf+ "</OBJECT>";-->

}
}

Printplayer (index);


/* Function J2s_onplayover () {
index++;
Printplayer (index);

} */

function S2j_onplayover () {
Alert (' SSSs ');
index++;
Printplayer (index);
}
</script>

Operation Effect:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.