About stopping the video stream in PhoneGap inappbrowser

I am using PhoneGap 2.4.0. for android application.

When I open an external web page (containing YouTube videos) using inappbrowser, the video plays well. But after closing the web page with the pressed button, the sound does not stop playing. To stop the video sound, I had to turn off the phone.

This is a big problem for me. Last time a week I tried to fix it.

Can i get help?


This is my code.

.......................

  function chamgae(juso) {
        var ref = window.open(juso, '_blank', 'location=yes');
        ref.close();
        }
..........................

<a href="#" onclick="chamgae('http://m.youtube.com')">

..........................

or

.......................

      function chamgae(juso) {
            window.open(juso, '_blank', 'location=yes');
            }
    ..........................

    <a href="#" onclick="chamgae('http://m.youtube.com')">

    ..........................
+2
source share
4 answers

You did .close () after opening InAppBrowser.

var ref = window.open(url, '_blank', 'location=no');
ref.close();

I deleted the .close () code and I had trouble continuing to play. This should solve your problem.

0
source

, _blank _self, , . , , , .

0

-. : -

var win = window.top;
win.onfocus = function() { };
win.onblur  = function() { fnDoSomething() };
function fnDoSomething(){
player=$f(document.getElementById('player_1'));
player.api('pause');
}

win.onblur , - , . , "" vimeo-.

.

0

SO, , Win10:

var ref = window.open(file, '_blank', 'location=yes,hardwareback=yes,fullscreen=yes');
ref.addEventListener('loadstop', function () {
    ref.executeScript({ file: "videofix.js" });
});

videofix.js:

var video = document.getElementsByTagName("video")[0];

let videoStopped = false;
// is executed every 100ms
var id = window.setInterval(function () {
    if (document.hidden && !videoStopped) {
        video.pause();
        videoStopped = true;
        // stop execution of this method
        window.clearInterval(id);
    }
}, 100);
0

All Articles