I think that Google means that u have to pause the youtube video when the app is in background mode (e.g. touching the device home button)
the way I solve it so register the 'pause' event (called when the app goes to background)
document.addEventListener("pause", pause, false);
function pause (argument) {
if (typeof document.app.player != "undefined") {
document.app.player.pauseVideo();
}
}
when a youtube is played I keep the reference of the player:
patt=/\/www\.youtube\.com\/watch\?v=(.*)/;
m = patt.exec(url);
if (m.length == 2) {
url = "http://www.youtube.com/embed/"+ m[1] //+ "?autoplay=1"
console.log("url = "+url)
}
YTid = 'yt_'+m[1];
$("#MediaPPSVideo").html(
"<div id='"+YTid+"' width=\"100%\"></div>"
).after(function() {
document.app.player = new YT.Player(YTid, {
height: $(window).height()/2,
width: $(window).width()*0.95,
videoId: m[1],
events: {
'onReady': onPlayerReady,
}
});
})
this ugly but working