SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Downloaden Sie, um offline zu lesen
HOW TO PLAY YOUTUBE VIDEOS ONE AFTER ANOTHER
We can use function getDuration() in "swfobject.js" with data retrieving
from the Google "gdata.feeds" webs. But the exactness in one or two
seconds seems to me is not necessary. So I take the easiest way, using
the familiar function setTimeout("..",1000). Next is the code.
<script>
function play(i){
c = 0;
window.scrollTo(0,0);
obj = document.getElementById("vidTitle");
obj.innerHTML = '<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 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);
}
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.
</script>
</head>
<body 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="Next" onclick="nextVideo()">
</div>

Weitere ähnliche Inhalte

Andere mochten auch (7)

Red Bull aston martin feature
Red Bull aston martin featureRed Bull aston martin feature
Red Bull aston martin feature
 
Maldonado feature
Maldonado featureMaldonado feature
Maldonado feature
 
Mi bio
Mi bioMi bio
Mi bio
 
LetterOfReference_JohnBrough
LetterOfReference_JohnBroughLetterOfReference_JohnBrough
LetterOfReference_JohnBrough
 
There is
There isThere is
There is
 
Summer fun flyer
Summer fun flyerSummer fun flyer
Summer fun flyer
 
Certificate: METT ADVANCED (Expert Level)
Certificate: METT ADVANCED (Expert Level)Certificate: METT ADVANCED (Expert Level)
Certificate: METT ADVANCED (Expert Level)
 

Mehr von phanhung20

Play audio-continuously
Play audio-continuouslyPlay audio-continuously
Play audio-continuously
phanhung20
 
Playing videos. See:slideshare.net/phanhung20/non-stop-random2b
Playing videos. See:slideshare.net/phanhung20/non-stop-random2bPlaying videos. See:slideshare.net/phanhung20/non-stop-random2b
Playing videos. See:slideshare.net/phanhung20/non-stop-random2b
phanhung20
 

Mehr von phanhung20 (20)

Graph for Coulomb damped oscillation
Graph for Coulomb damped oscillationGraph for Coulomb damped oscillation
Graph for Coulomb damped oscillation
 
Search videos with youtube api3
Search videos with youtube api3Search videos with youtube api3
Search videos with youtube api3
 
Search and play more than 50 clips
Search and play more than 50 clipsSearch and play more than 50 clips
Search and play more than 50 clips
 
Search 500-video-clips
Search 500-video-clipsSearch 500-video-clips
Search 500-video-clips
 
Color ss2-pvh-bta1
Color ss2-pvh-bta1Color ss2-pvh-bta1
Color ss2-pvh-bta1
 
Pvh bai-tap-a2-2014-th-11(1)
Pvh bai-tap-a2-2014-th-11(1)Pvh bai-tap-a2-2014-th-11(1)
Pvh bai-tap-a2-2014-th-11(1)
 
Cau hoi thi vatly 2014 4 tin chi
Cau hoi thi vatly 2014 4 tin chiCau hoi thi vatly 2014 4 tin chi
Cau hoi thi vatly 2014 4 tin chi
 
Cau hoi-thi-catly-2014-thang11
Cau hoi-thi-catly-2014-thang11Cau hoi-thi-catly-2014-thang11
Cau hoi-thi-catly-2014-thang11
 
Pvh 11-2014-btvl-a1
Pvh 11-2014-btvl-a1Pvh 11-2014-btvl-a1
Pvh 11-2014-btvl-a1
 
Debai table1
Debai table1Debai table1
Debai table1
 
Bai tap-a1
Bai tap-a1Bai tap-a1
Bai tap-a1
 
Thi nghiema2
Thi nghiema2Thi nghiema2
Thi nghiema2
 
Thi nghiema1
Thi nghiema1Thi nghiema1
Thi nghiema1
 
Ly thuyetdosai so1
Ly thuyetdosai so1Ly thuyetdosai so1
Ly thuyetdosai so1
 
Bai tap a1
Bai tap a1Bai tap a1
Bai tap a1
 
Play audio-continuously
Play audio-continuouslyPlay audio-continuously
Play audio-continuously
 
How to-save-video-list
How to-save-video-listHow to-save-video-list
How to-save-video-list
 
Xem video-lien-tuc
Xem video-lien-tucXem video-lien-tuc
Xem video-lien-tuc
 
Non stop random2b
Non stop random2bNon stop random2b
Non stop random2b
 
Playing videos. See:slideshare.net/phanhung20/non-stop-random2b
Playing videos. See:slideshare.net/phanhung20/non-stop-random2bPlaying videos. See:slideshare.net/phanhung20/non-stop-random2b
Playing videos. See:slideshare.net/phanhung20/non-stop-random2b
 

Kürzlich hochgeladen

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Kürzlich hochgeladen (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

Nonstop vid. See newer: http://www.slideshare.net/phanhung20/playing-videos-continuously

  • 1. HOW TO PLAY YOUTUBE VIDEOS ONE AFTER ANOTHER We can use function getDuration() in "swfobject.js" with data retrieving from the Google "gdata.feeds" webs. But the exactness in one or two seconds seems to me is not necessary. So I take the easiest way, using the familiar function setTimeout("..",1000). Next is the code. <script> function play(i){ c = 0; window.scrollTo(0,0); obj = document.getElementById("vidTitle"); obj.innerHTML = '<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 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); } function d(du){ dur.push(du); } function quit(){ if(mytimer){ clearTimeout(mytimer); }
  • 2. } //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. </script> </head> <body 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="Next" onclick="nextVideo()"> </div>