Hey,
I have created the app using ionic framework and All i have done is just embedded a YouTube embed code , I have handled the case that it should not allow the app to keep the video playing in the background but am still not able to publish my applicaion and I pause the video embeded in iframe on hardware back key as well
Any Idea what am doing wrong
here’s the code:
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// ‘starter’ is the name of this angular module example (also set in a attribute in index.html)
// the 2nd parameter is an array of 'requires’
angular.module(‘starter’, [‘ionic’,‘ngCordova’])
.run(function($ionicPlatform,$rootScope,$cordovaPush,$ionicPopup,$state,$location,$http) {
$ionicPlatform.ready(function() {
if(window.StatusBar) {
StatusBar.styleDefault();
}
if(window.Connection) {
//alert(navigator.connection.type );
if(navigator.connection.type == Connection.NONE) {
//alert(“no connection”);
$ionicPopup.alert({
title: ‘No Internet Connection’,
content: ‘Sorry, you are not connected to internet, app will exit. Try again with internet connection on’
})
.then(function(result) {
ionic.Platform.exitApp();
});
}
}
});
$ionicPlatform.registerBackButtonAction(function(event) {
if (true) { // your check here
$ionicPopup.confirm({
title: ‘Exiting the application’,
template: ‘Are you sure you want to exit?’
}).then(function(res){
if( res ){
var iframe = document.getElementsByTagName(“iframe”)[0].contentWindow;
iframe.postMessage(’{“event”:“command”,“func”:"’ + ‘stopVideo’ + ‘",“args”:""}’, ‘*’);
navigator.app.exitApp();
}
})
}
}, 100);
})
Index.html
<ion-content>
<p class="">
<iframe width="100%" height="480" src="https://www.youtube.com/embed/2WRgZuZKics?enablejsapi=1" frameborder="0" allowfullscreen></iframe>
</p>
</ion-content>
Any idea what am doing wrong here