In this demo, we want to make simple links (A
href tags) that will play avideo file in Flowplayer. While you can achieve this functionality using theplaylist plugin, this implementation is much simpler and does not depend onjQuery or the playlist
plugin itself.
<style>
<!--
#content div.row
{margin:30px 0pt;
padding:20px;
width:705px}
#clips
{margin-left:12px}
#clips a
{color:lightblue}
#clips a:hover
{color:rgb(237,237,237)}
-->
</style>
The drawback compared to using playlist plugin is that those links are nottied to the player in any way. They simply start a movie clip from thebeginning each time they are clicked. They have no states such as loading,playing or paused.
HTML
<a
href="KimAronson-TwentySeconds70930.flv"
style="display:block;width:400px;height:300px;"
id="player">
</a>
<div id="clips">
<a href="KimAronson-TwentySeconds70930.flv">Eating sushi</a>
<a href="KimAronson-TwentySeconds64268.flv">Hotel room with brown carpet</a>
<a href="KimAronson-TwentySeconds63617.flv">Small lake and a bicycle</a>
</div>
<br clear="all" />
HTML
Configuration
$f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.8.swf", {
clip: {
// use baseUrl so we can play with shorter file names
baseUrl: 'http://blip.tv/file/get',
// use first frame of the clip as a splash screen
autoPlay: false,
autoBuffering: true
}
});
// get all links that are inside div#clips
var links = document.getElementById("clips").getElementsByTagName("a");
// loop those links and alter their click behaviour
for (var i = 0; i < links.length; i++) {
links[i].onclick = function() {
// play the clip specified in href- attribute with Flowplayer
$f().play(this.getAttribute("href", 2));
// by returning false normal link behaviour is skipped
return false;
}
}