Setup clustering for your video servers Streaming plugin extensions - Demo 4 / 10
Introduction
The Cluster plugin is 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 following splash image and you can see how the plugin attempts to retrieve video file from the first available server.
HTML coding
Here we have the player container and the info box.
<a
href="flowplayer-700.flv"
style="display:block;width:425px;height:300px;"
id="player">
<!-- splash image inside the container -->
<img src="/img/home/flow_eye.jpg" alt="Search engine friendly content" />
</a>
<div class="box" id="info">
<h2>Events related to the cluster appear here:</h2>
</div>
Flowplayer configuration
We use flowplayer.cluster-3.1.1.swf plugin for the clustering. It is configured with multiple streaming servers in hosts property. First two hosts are imaginary hosts that does not respond. The third one should answer. Here we demonstrate two different callback methods that are used to update the info box below the player container.
// a global variable that references our info box
var info = document.getElementById("info");
flowplayer("player", "/swf/flowplayer-3.1.5.swf", {
log: { level: 'debug', filter: 'org.flowplayer.cluster.*' },
plugins: {
// cluster plugin configuration
cluster: {
url: 'flowplayer.cluster-3.1.1.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://static.flowplayer.org/video'
],
// 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;
}
}
});