From 68579f3a451b910ffa47ed9cc7414a5e0338105f Mon Sep 17 00:00:00 2001 From: Ludovic Barman Date: Sun, 11 May 2014 13:47:28 +0200 Subject: Working version YoutubePlayer --- app/js/yt_musicsearch.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/js/yt_musicsearch.js') diff --git a/app/js/yt_musicsearch.js b/app/js/yt_musicsearch.js index fcc52db..82ad741 100644 --- a/app/js/yt_musicsearch.js +++ b/app/js/yt_musicsearch.js @@ -18,12 +18,22 @@ function searchClicked() document.documentElement.firstChild.appendChild(script); } - - function newMusic(id) + + var musicTimer; + + function startSongWithDuration(id, duration) { $('#ytplayer').attr('src', 'https://www.youtube.com/embed/'+id+'?autoplay=1&modestbranding=1'); + console.log("Starting music "+id+", timer="+duration); + musicTimer = setInterval(changeSong, duration * 1000); } - + + function changeSong() + { + alert("Done"); + clearInterval(musicTimer); + } + function getAllMatchingIds(data) { var feed = data.feed; @@ -44,7 +54,7 @@ function searchClicked() for (var i = 0; i < results.length; i++) { //html.push('
  • ', '', results[i].title, '(', results[i].duration, ')', '
  • '); - html.push('
  • ', '', results[i].title, '', '
  • '); + html.push('
  • ', '', results[i].title, '', '
  • '); } html.push(''); document.getElementById('videoResultsDiv').innerHTML = html.join(''); -- cgit v1.2.3