playing videos continously

10

Click here to load reader

Upload: phanhung20

Post on 22-Jun-2015

198 views

Category:

Education


1 download

DESCRIPTION

How to use javascript to make a web page for playing videos continously

TRANSCRIPT

Page 1: Playing videos continously

1

HOW TO MAKE WEB PAGE WITH VIDEOS PLAYING CONTINUOUSLY

We can use function getDuration() in "swfobject.js" with data retrieved from the Google "gdata.feeds" webs. But the fact that pause between videos is shorter or longer in one or two seconds is not important. Because of it, I take the easiest way, using the familiar function setTimeout("..",1000) to control the change of videos. You can try this web page at address: https://files.myopera.com/phanhung20/files/nonstop-simple3.html and download RAR file (three files: nonstop-simple3.html, myList1.js, playing-videos.pdf) from: http://www.mediafire.com/download/903gf057br6jzo7/nonstop-videos.rar

Pic. 1- The web page nonstop-simple3.html

The main html file “nonstop-simple3.html” stores information of only six videos. Other 66 video’s information is saved in a javascript file “myList1.js”. You can easily add more videos by typing for each new video three elements: 1- Title of video: You must avoid to write any double quotation marks inside a pair of beginning and ending ones and

need to rewrite those marks “ to \”. For example:

This line: t("Evita "Don't Cry For Me Argentina", Francis Goya") ; will halt the web at once.

Page 2: Playing videos continously

2

The right script is: t("Evita \"Don't Cry For Me Argentina\", Francis Goya") ;

2- Id (Identifier) of video: v(“TrwKuoF-WOo“);

Pic. 2 – Id (11 characters-numbers) is at the end of address of the web (click in it to see full content)

3- duration - the time elapse of the video: d(265);

I have retrieved 265 seconds from gdata web. But in youtube web we see 4:24 (264 seconds).

Pic. 3 – duration (4:24) and title ((HD 720p) “Don’t Cry …) shown in youtube.com page

Title can be freely changed, but Id and duration must be exact as you see them in youtube.com web

page.

There is an extract from “myList1.js”:

t("Mal... CHRISTOPHE... oneiraki") ;

v("dueE06-rzbk");d(216);

t("Helmut Lotti - \"Those Were The Days\"") ;

v("tX2sVv3yYgE");d(233);

t("Sen Masao _ Kitagunino Haru") ;

v("0kHyeZDDwl4");d(163);

Two file “nonstop-simple3.html” (4.7 KB) and “myList1.js” (4.6 KB), can be downloaded to your PC, using

the links and they must be placed in the same folder: https://files.myopera.com/phanhung20/files/nonstop-simple3.html https://files.myopera.com/phanhung20/files/myList1.js The whole source codes of those files are shown here.

Page 3: Playing videos continously

3

nonstop-simple3.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Continously Playing</title> <head> <style> body{ background-color:#999; font-family:Arial; font-size:12px; } a { text-decoration:none; color:blue; } a:hover { text-decoration:underline; color: #0099ff; } #list1{ width: 640px; /*850px*/ height: 130px; margin:0px; padding:0px; border:1px solid #666; text-align:left; overflow:auto; background-color:#ddd; line-height:150%; } </style> <script> function play(i){ c = 0; window.scrollTo(0,0); obj = document.getElementById("vidTitle");

Page 4: Playing videos continously

4

last = last = vid.length - 1; obj.innerHTML = '['+ j + ' / total:'+ last +']&nbsp;&nbsp;<b>'+tit[i]+ '</b>'; obj = document.getElementById("player1"); stID = "http://www.youtube.com/embed/" + vid[i] + "?autoplay=1"; obj.setAttribute("src",stID); } var c = 0; var j = 0; function count(){ last = vid.length - 1; c = c + 1; obj = document.getElementById("showSeconds"); obj.value = c + " / dur:" + dur[j]; if(c>dur[j]){ if(j<=last){j=j+1; play(j)} if (j>last){j=1;play(j)} } mytimer = setTimeout("count()",1000); } function backVideo(){ len = vid.length -1; if(j>=2){j=j-1;play(j);} if (j==1){play(j);alert("Begin Of List");} } function nextVideo(){ last = vid.length -1; if(j<=last){j=j+1;play(j);} if (j>last){j=1;play(j);} } function endVid(){ clearTimeout(mytimer); st = "http://www.youtube.com/embed/ntGJ2vkLbIo?autoplay=0"; obj = document.getElementById("player1"); obj.setAttribute("src",st); obj = document.getElementById("vidTitle"); obj.innerHTML = ''; c = 0; j = 0; } function sec(m,s){ return m*60 + s; } function t(ti){ tit.push(ti); } function v(vi){ vid.push(vi); }

Page 5: Playing videos continously

5

function d(du){ dur.push(du); } function quit(){ if(mytimer){ clearTimeout(mytimer); } } //Creating three arrays tit = []; vid = []; dur = []; k=0; tit[k]="" ;vid[k]="" ;dur[k]=0; t("Richard Abel - Spanish Eyes") ; v("ntGJ2vkLbIo");d(183); t("CUANDO SALI DE CUBA- SUSANA PEÑA"); v("9CLAAJYRo-I");d(95); t("FRANCK POURCELL - BESAME MUCHO"); v("RK208ZT82Is");d(sec(3,12)); // In the youtube.com page "franck pourcel besame mucho" // you see: duration of the video is 3:12. Function sec(..) will return 192 seconds. t("Evita \"Don't Cry For Me Argentina\", Francis Goya") ; v("TrwKuoF-WOo");d(265); // t("NO MATTER WHAT _ Francis Goya & RICHARD CLAYDERMAN") ; v("NPer39-JSr0");d(214); t("The old rowan tree") ; v("wmt16uvPDqg");d(161); function init(){ ss = ''; len = vid.length; for (i=1;i<len;i++){ xx = '<li><a href="#" onclick="j =' + i +'; play(' + i+');">'+ tit[i]+ '</a><br>'; // them j = i; ss = ss + xx; } obj = document.getElementById('list1'); obj.innerHTML = '<ol><br>' + ss + '</ol>'; } </script> <script type="text/javascript" src="myList1.js"></script>

Page 6: Playing videos continously

6

</head> <body onload="init()" onload="quit()"> <div align="center"> <iframe id="player1" width="835" height="480" src="http://www.youtube.com/embed/ntGJ2vkLbIo?autoplay=0" frameborder="0" allowfullscreen ></iframe> <br> You are watching: <br><span id="vidTitle"></span> <br> <input type="button" value="Play All" onclick="count()">&nbsp; <input type="button" value="End" onclick="endVid()">&nbsp; <input type="text" id="showSeconds" value="0/dur" size=28 style="text-align:center">&nbsp; <input type="button" value="Back" onclick = "backVideo();">&nbsp; <input type="button" value="Next" onclick="nextVideo()"> <br> <br> <div id="list1"> </div> <br> <iframe src="http://www.slideshare.net/slideshow/embed_code/21827746" width="835" height="560" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC;border-width:1px 1px 0;margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="http://www.slideshare.net/phanhung20/nonstop-vid" title="Nonstop vid" target="_blank">Nonstop vid</a> </strong> from <strong><a href="http://www.slideshare.net/phanhung20" target="_blank">phanhung20</a></strong> </div> <br> </div> </body> </html>

myList1.js t("Che Sara, Rocco Granata") ; v("mdlE_FTym7I");d(224); t("Je T\'aime Mon Amour ~ Claudia Jung & Richard Clayd") ; v("ZNFxeAOZRY0");d(236); t("Madonna - 26 Years of La Isla Bonita") ; v("dhPkFXGlfds");d(261); t("Besame mucho - saxo soprano") ; v("AHZUf3tfZE8");d(237); t("Humayun's Tomb") ; //documentary

Page 7: Playing videos continously

7

v("uuWAMfejnLI");d(265); t("Smokie - Needles And Pins") ; v("pa648JF3SoU");d(159); t("Feelings... - Romantic Violin") ; v("owBLIJBLbJo");d(230); t("Michael Learns to Rock - That's Why (You Go Away) Live") ; v("HaBIQ7TRYbs");d(258); t("Richard clayderman Dancing Queen") ; v("xSv5XhAZQHA");d(231); t("Richard Clayderman - ABBA - Fernando.mp4") ; v("Kidut_LpYS0");d(267); t("Green Green Grass Of Home - Tom Jones & Englebert Humperdink ( with lyrics )") ; v("t5CdDpe87eM");d(186); t("TOM JONES - PLEASE RELEASE ME (LIVE)") ; v("AY3JJnL4Fz4");d(148); t("Richard Clayderman & Francis Goya - My Heart Will Go On") ; v("3EC-xqcSGfg");d(285); t("VIDEO--AMORE--AMOR .--FRANCIS GOYA") ; v("B2XYGgoYu5U");d(205); t("GOODBYE MY LOVE GOODBYE--FRANCIS GOYA") ; v("-gnTgDeo-x8");d(172); t("The Moon Represents My Heart") ; v("Y-4q0ylUS6k");d(217); t("O sole mio - Graziano") ; v("qA4PjcqOXQo");d(197); t("FRANCIS GOYA - WHEN YOU TELL ME THAT YOU LOVE ME") ; v("y5omkOu12S4");d(246); t("SOMEWHERE MY LOVE - Billy Vaughn") ; v("X5caDaz-_Ko");d(120); t("Sigrid & Marina - Santa Lucia 2010") ; v("uNDg3yObq4E");d(183);

Page 8: Playing videos continously

8

t("HAWAII - Aloha Oe") ; v("-fOQmQCtBbM");d(207); t("Karaoke (in spanish) - CUANDO CALIENTA EL SOL") ; v("uSbtp4EY_sU");d(148); t("Quando Quando Quando") ; v("AiMTmh6MrqQ");d(193); t("Mantovani & Orchestra - Amapola") ; v("3tDmmwMnUYU");d(168); t("Solamente Una Vez You Belong To My Heart Performed On Yamaha Tyros 4 By Rico") ; v("JahmgMw996w");d(166); t("BAILAMOS ** QUOC KHANH") ; v("dFv8LqxMJHs");d(276); t("Rhythms del mundo - Hotel California") ; v("fCKHLjOCZi0");d(416); t("ABBA I Do, I Do, I Do, I Do, I Do Performed On Yamaha Tyros 4") ; v("CUAIYIh932M");d(218); t("Guantanamera") ; v("nkHz1hCJUqE");d(169); t("Apache - Hank Marvin - 2000") ; v("RB91ayDlQLE");d(196); t("Chiquitita - Richard Clayderman") ; v("x0fe8zqK2Y8");d(217); t("You dont have to say you love me - Romantic , instrumental 200ic") ; v("SNTrJIIom3w");d(196); t("Robertino Loretti - Schubert - Serenata") ; v("ASuQ7oVH2yE");d(172); t("Toto Cutugno - Clandestino") ; v("BGz--IIgJQo");d(200); t("Lê Toàn - Cha Tôi (Papa)") ; v("mMumDBAed_Q");d(283); t("Yesterday - Mantovani Orchestra") ; v("oW2SDwSJrLg");d(205); t("Stranger on the Shore - by Boots Randolph") ;

Page 9: Playing videos continously

9

v("sv6FH5tlWZg");d(202); t("Smokie - Needles and Pins 1977") ; v("7beP1eIeVNI");d(139); t("TOM JONES - Delilah (1968)") ; v("8a_T3U1rg2I");d(213); t("Triệu Đóa Hoa Hồng - Gia Huy") ; v("_zJPXFCk5Ak");d(279); t("HÒA TẤU GUITAR 04") ; v("G2luX73arA8");d(173); t("Mua Thu La Bay - Karaoke") ; v("UCxs6YsL6xo");d(212); t("Biscaya") ; v("x-32fx-AcYI");d(243); t("Franck Pourcel - Adieu, jolie Candy (1969)") ; v("w8eAKPRO8O0");d(180); t("Donna Donna Kinh điển nhạc Pháp") ; v("RmsWnZXVIaI");d(144); t("Khi xưa ta bé - Karaoke") ; v("CDv9iSnlbJ4");d(303); t("Pardonne moi ce caprice - Mathiew") ; v("C-Lh0lhsOhw");d(200); t("Tuyết Rơi (Tombe La Neige) - Ngọc Lan") ; v("ji9CW85d7UQ");d(375); t("Mal... CHRISTOPHE... oneiraki") ; v("dueE06-rzbk");d(216); t("Helmut Lotti - \"Those Were The Days\"") ; v("tX2sVv3yYgE");d(233); t("Sen Masao _ Kitagunino Haru") ; v("0kHyeZDDwl4");d(163); t("Hana (Flower)") ; v("1taY9sBRyZs");d(176);

Page 10: Playing videos continously

10

t("Teresa Teng ♪ Toki no Nagare ni mi o Makase ♪ Legendado ♪ HD Video") ; v("_yMALArKnEU");d(200); t("KARAOKE -Xin thời gian ngừng trôi Ngọc Lan") ; v("hoxUYh4fVnQ");d(238); t("Airport - Japan 200ic") ; v("-RF7vr9Uw9I");d(230); t("Trio Ambisi - Asing Sing So") ; v("Av1Ilext1wE");d(269); t("Rudy Wairata - Rayuan Pulau Kelapa") ; v("4--RjaheiVg");d(191); t("Rayuan Pulau Kelapa, Habil prod.mpg") ; v("9hzt0qeIZrM");d(314); t("Bengawan Solo - A Duet in Indonesian") ; v("cxyJ49awbt4");d(246); t("Ayo Mama") ; v("g-cog8ueNJA");d(226); t("Andy Tielman Bengawan Solo") ; v("ATo8qV4Cgaw");d(222); t("Teresa Teng - 恰似你的 ") ; v("1WqhF6hRiiM");d(248); t("Vuong Phi - No Regrets") ; v("-7ruFFLOgsQ");d(269); t("Yi Qi Zou Guo De Ri - (Liu De Hua) in chinese-cantonese") ; v("EKy_E64Xd7A");d(235); t("Journey to the West - Girl's Love - Tinh nu nhi - by pvhung20") ; v("eVizTSJ80bo");d(274); t("The best of instrumental .-Francis Goya(Quiero)") ; v("10z3c8Q35O8");d(201);

May 25, 2013 - phanhung20