Client side clustering
Events related to the cluster appear here:
The Cluster plugin can be used to configure multiple streaming sources. By having multiple sources we gain reliability because the viewer is not affected if some of the sources are not available. We also gain performance because we can balance the load by sending the viewers to several servers. Click on the above splash image and you can see how the plugin attempts to retrieve the video file from the first available server.
HTML
<!-- player container-->
<a href="Extremists.flv" class="player"
style="display:block;width:425px;height:300px;margin:10px auto"
id="player">
<!-- splash image inside the container -->
<img src="/media/img/home/flow_eye.jpg"
alt="Search engine friendly content" /></a>
Configuration
The [Cluster plugin][FPCluster] is configured with multiple streaming servers in its
hosts property. The first two hosts are imaginary hosts which do not respond. The
third one should answer. Here we also demonstrate two different callback methods to
update the info box below the player container.
// a global variable that references our info box
var info = document.getElementById("info");
flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.11.swf", {
log: { level: 'debug', filter: 'org.flowplayer.cluster.*' },
plugins: {
// cluster plugin configuration
cluster: {
url: "http://releases.flowplayer.org/swf/flowplayer.cluster-3.2.8.swf",
// our hosts on the cluster
hosts: [
// first two hosts will fail
'http://invalid.flowplayer.org/video',
'http://nonexistent.flowplayer.org/video',
// this one will answer (if the server is up)
'http://pseudo01.hddn.com/vod/demo.flowplayervod'
],
// callback method for connection attempt
onConnect: function(host, index) {
info.innerHTML += "attempting to connect: " + host + "<br />";
},
// callback method for connection failure
onConnectFailed: function(host, index) {
info.innerHTML += "connection failed to: " + host + "<br />";
}
}
},
// use our cluster plugin as a "URL resolver"
clip: {
urlResolvers: 'cluster',
onStart: function(clip) {
info.innerHTML += "clip started: " + clip.url;
}
}
});
