2011-08-23 101 views
1

我目前正在爲一個騎車網站開發項目,在那裏他們有一小部分鍛鍊歌曲。其中一些歌曲與YouTube視頻有鏈接,因此您可以聽到歌曲。嵌入式YouTube視頻的自定義播放按鈕

我必須做到這一點,所以在歌曲的概述中,有一個小的播放按鈕,點擊後可播放選定的YouTube視頻。但視頻應該隱藏,所以你只能聽到音樂。

點擊後,按鈕變爲暫停或停止按鈕,因此您可以再次停止音樂。

但我可以找出有關youtube或其他媒體的指導方針。 所以我希望我能在這裏得到一些幫助。

該網站必須加載至少10個YouTube視頻,並且他們都應該有自定義播放/停止按鈕。那麼誰能幫助我呢? :)

感謝

- 托馬斯

+0

http://superuser.com/questions/104932/how-to-watch-youtube-downloading-only-the-audio-流似乎表明這不是一個簡單的方法來做到這一點。 You Tube API甚至允許這麼做嗎? –

+0

http://code.google.com/intl/da/apis/youtube/youtube_player_demo.html - 它確實看起來像有一些自定義播放/停止按鈕。只是無法弄清楚我將如何使它與更多的YouTube視頻一起工作。爲了隱藏他們,你可以使用style =「display:none;」。 – uman

回答

0
<? 
$yt_video = "http://www.youtube.com/watch?v=AfgdUfDgCq8"; 

$jw = <<< EOF 

<script type='text/javascript' src='jwplayer.js'></script> 
<div id='mediaspace' style="display:none;visibility:hidden;">This text will be replaced</div> 

<script type='text/javascript'> 
    jwplayer('mediaspace').setup({ 
    'flashplayer': 'http://player.longtailvideo.com/player.swf', 
    'file': '{$yt_video}', 
    'controlbar': 'bottom', 
    'width': '1', 
    'height': '1', 
    'autostart': 'true' 
    }); 
</script> 
EOF; 

echo $jw; 

?> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('PLAY');return false;">play/pause toggle</a><br /> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('LOAD', 'http://www.youtube.com/watch?v=ZNXUXujoX4M'); return false;">Video 1</a><br /> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('LOAD', 'http://www.youtube.com/watch?v=gE5tOEU7ymU'); return false;">Video 2</a><br /> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('LOAD', 'http://politicos.biz/stack/playlist.xml'); return false;">Load Playlist</a><br /> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('NEXT'); return false;">Next Video on Playlist</a><br /> 
<a href="#" onclick="javascript:document.getElementById('mediaspace').sendEvent('PREV'); return false;">Previous Video on Playlist</a><br /> 

你需要下載http://www.longtailvideo.com/players/jw-flv-player/和改變jwplayer.jsplayer.swf(可選)的位置。您還需要創建一個crossdomain.xml文件並將其放置在您的域的根文件夾中。

我希望它能幫助你:)

活生生的例子@http://x.co/ZEpd

相關問題