Alright, here's my code for weather.com and my Weather Channel app. It's a pretty straight forward controller file and it works with the current video media feed I'm pushing out for the app. For right now until team boxee adds it to the official helper2 directory, just drop the below code in a file called weather.js and save it to the /boxee/system/players/flashplayer directory. Note this is the boxee directory where the boxee executable is and not where your userdata is.
The controller basically polls the player window every 500ms for visual changes (using getPixel). It first verifies that the media is loaded and ads are no longer playing. When that happens the video window is maximized full screen. Polling continues until the player window is detected as being in a stopped state momentarily. As soon as that happens a notifier is sent to axe the player window.
Let me know if you have any questions at all as I'm getting pretty good at understanding what all the javascript does at this point. I tried to comment some of the stuff, but everyone reads things differently.
Code:
// config options
boxee.autoChoosePlayer = true;
boxee.renderBrowser = false;
boxee.enableLog(true);
boxee.setCanPause(false);
boxee.setCanSkip(false);
boxee.setCanSetVolume(false);
var isPlaying = false;
/* func: R/G/B
* desc: used for converting pixel colors to RGB
*/
function R(p) { return (p & 0x00ff0000) >> 16; }
function G(p) { return (p & 0x0000ff00) >> 8; }
function B(p) { return (p & 0x000000ff) ; }
/* func: poll
* desc: continuously monitors the player status
*/
function poll() {
if (isLoaded() && isStopped()) {
boxee.notifyPlaybackEnded();
}
else if (isLoaded() && (isPlaying == false)) {
boxee.getActiveWidget().click(387, 457);
isPlaying = true;
}
}
setInterval(poll, 500);
/* func: getProgress
* desc: monitors the progress bar on the player, but
* deprecated due to inability to monitor progress
* when player is maximized to full screen status
function getProgress() {
if (!isLoaded()) {
return -1;
}
var i = 0.0;
for (x=75; x<435; x+=5) {
p = boxee.getActiveWidget().getPixel(x, 434);
if ((r >= 160) && (r <= 200)) break;
if ((g >= 160) && (g <= 200)) break;
if ((b >= 160) && (b <= 200)) break;
i+=5;
}
return Math.round((i/360)*100);
}
*/
/* func: isLoaded
* desc: media is loaded and ads are not playing
*/
function isLoaded() {
p = boxee.getActiveWidget().getPixel(172, 455);
b = B(p);
g = G(p);
r = R(p);
if ((r >= 160) || (r <= 70)) return false;
if ((g >= 160) || (g <= 70)) return false;
if ((b >= 160) || (b <= 70)) return false;
return true;
}
/* func: isStopped
* desc: media has stopped playing
*/
function isStopped() {
p = boxee.getActiveWidget().getPixel(255, 220);
b = B(p);
g = G(p);
r = R(p);
if ((r <= 20) || (r >= 100)) return false;
if ((g <= 20) || (g >= 100)) return false;
if ((b <= 20) || (b >= 100)) return false;
return true;
}
Bookmarks