9 Aug 2011

Get annoyed when veetle broadcast stops ?

As a "Friends" series fans, I like to watch it on Veetle. But somehow, it stops broadcast sometimes and shows a message of temporarily off air and need reloading. While I am lying down on bed to watch, it is quite annoying. So I developed a script to get rid.

This script is written using Javascript under Greasemonkey environment, an add-in extension for firefox. All you need is installing Greasemonkey and put this script in as a new script.

After you enable this script, every time you open the Veetle channel view, it will show you a button in top left corner of your web browser captioned "click me". In essence, this script is a timer program that periodically checks whether the video plugin is running or not. The click me button is a toggle button for activating the checker timer.

This program is still rough i guess, but believe me, this is useful..

Okay, let us try it.



// ==UserScript==
// @name veetle refresher
// @namespace http://www.veetle.com/index.php/channel/view*
// @description mine
// @include http://www.veetle.com/index.php/channel/view*
// ==/UserScript==

var checker=0;
var myint;

function check() {
var ongko=0;
if (checker==0) {
checker=1;
myint=window.setInterval(function(e) {
var isplaying = unsafeWindow.VEETLE.Players.instance().getPlayer().isPlaying();
var isfull = unsafeWindow.VEETLE.Players.instance().getPlayer().isFullScreen();


ongko++;
if (ongko>5) {
ongko=0;
if (isplaying==false) {
unsafeWindow.VEETLE.bootstrap.play();
} else {
if (isfull==false) {
unsafeWindow.VEETLE.Players.instance().getPlayer().fullScreen();
}
}
}
document.getElementById('mb').innerHTML=String(ongko)+'---'+String(isplaying)+"--"+String(isfull);
},1000);

} else {
window.clearInterval(myint);
document.getElementById('mb').innerHTML='click me';
checker=0;
}
}



var g=document.createElement('div');
g.innerHTML='';
g.style.position='fixed';
g.style.left=0;
g.style.top=0;
g.addEventListener('click',function () {
check();
},false);

document.body.appendChild(g);