InAppBrowser instance stays open in background on close button click

Welcome! Forums Unity Plugins In-App Web Browser InAppBrowser instance stays open in background on close button click

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #2163
    SanketSanket
    Participant

    Hi Piotr,

    I am facing this issue where on closing the InAppBrowser by clicking the close button in the title bar of the browser, it just hides the browser panel and does not close the browser entirely. Now the reason this is an issue for me as I am streaming a video in the browser and when I close the browser, I am still able to hear the sound of the video and my in-game sound simply mutes.

    I am using the latest version of InAppBrowser 2.0.2 with Unity 2019.4.7 and I have tried it on both android Xiaomi Poco f1 and Moto X and iOS device iPad 6th Generation.

    I am simply opening the InAppBrowser using below static util:

    public static void PlayVideoInBrowser(string url, string title)
    {
    if (IsUnityEditor())
    {
    Application.OpenURL(url);
    }
    else
    {
    InAppBrowser.DisplayOptions browserOptions = new InAppBrowser.DisplayOptions();
    browserOptions.backButtonText = ” X”; //white spaces for left padding
    browserOptions.shouldStickToLandscape = true;
    browserOptions.shouldUsePlaybackCategory = true;
    browserOptions.displayURLAsPageTitle = false;
    if (!isStringDefined(title))
    {
    title = “Video”;
    }
    browserOptions.pageTitle = title;
    browserOptions.hidesTopBar = false;
    browserOptions.shouldStickToLandscape = true;
    browserOptions.hidesHistoryButtons = true;
    browserOptions.textColor = Constants.WHITE_COLOR;
    browserOptions.barBackgroundColor = Constants.DARK_GREY_COLOR;
    browserOptions.loadingIndicatorColor = Constants.RED_COLOR;
    InAppBrowser.OpenURL(url, browserOptions);
    }
    }

    How can I close the browser instance fully to hear back the audio of the game?

    Please let me if there is there any quick workaround or if I am not using the plugin correctly.

    #2172
    PiotrPiotr
    Keymaster

    Could you give me a URL to a video you are testing? Browser is definitely closed, probably video asset isn’t released correctly and it’s run by some other process.

    #2173
    SanketSanket
    Participant

    You can try this URL: https://www.triumdesigns.com/media/default.mp4

    I guess when the browser plays a video, it might be using the internal video player of the corresponding platform and this internal video player does not get closed on browser close. I can say this from the video player UI on iOS. The player keeps on playing the video in the background when I close the InAppBrowser while the video is playing. You will still be able to hear the sound of the video after closing the browser. If I pause the video and then close the browser, it works normally.

    Let me know if I can somehow work around this.

    #2185
    enupgames
    Participant

    Same problem here.
    Definitely inconsistent.
    Still trying to figure out the exact conditions when it occurs.

    #2186
    PiotrPiotr
    Keymaster

    btw. why are you using this plugin to play videos?
    Isn’t Unity already providing API for videos?

    #2187
    SanketSanket
    Participant

    Well, you are right, Unity does have a Video playing API to play videos, but it is quite bad for streaming online videos.

    The native implementation of InAppBrowser allows it to use native video players that are far better at streaming online videos than Unity’s API. While in fact, it does stream our videos quite well, but only on browser close, the native video player still keeps on playing the video in the background.

    #2199
    enupgames
    Participant

    Is this something you’ll get a chance to work on
    sooner or later or..

    #2205
    PiotrPiotr
    Keymaster

    I am not able to reproduce it.
    Let’s talk about iOS:

    How is this video playing on iOS after clicking on a back button?
    After video starts playing I see close button coming from a player, so I click on it. Then I can click on a back button from browser but video is already closed – so how is it possible the audio is still playing for you?

    Here is screenshot from it:
    screenshot

    #2209
    enupgames
    Participant

    Ah, you nailed the clue.
    It was inconsistent because of how I was viewing the video.
    If I close with the X on video, everything is fine.

    But if I shrink the video with a zoom action (0:22),
    it continues to play inside the browser window.
    Then if I close it, the audio continues to play.

    I’m guessing the short term solution is for us to just disable the pinch and zoom.

    #2210
    enupgames
    Participant

    Never mind on disabling pinch/zoom.
    Pinch/zoom in only in relation to the inappbrowser window.
    Turning it off doesn’t stop me from ‘minimizing’ the video window.

    #2214
    PiotrPiotr
    Keymaster

    Ok, could you guys try it out:
    – There is InAppBrowser.jar file in Plugins/Android: replace it with this.
    – There is InAppWebBrowser.a file in Plugins/iOS: replace it with this.

    Looking forward for your feedback.

    #2216
    SanketSanket
    Participant

    Hi,

    I tried the new jar file in the project that I shared with you on email, but it still doesn’t seem to solve my issue of in-game sound going mute on closing the IAB.

    You can try the project I shared with you where I have just edited your sample scene to have a text box to enter a URL to be opened in IAB on button click. And I am having a background score playing on a loop in the background.

    I tried the new InAppBrowser.jar, that you shared, in this project and the results are still the same, the in-game sound goes on mute on closing the browser playing a video.

    Just FYI, the unity project is on my google drive here:
    https://drive.google.com/drive/folders/113b4PUcR5Pq5FL2dVBdgo6vh8k6ZxH_n?usp=sharing

    Hope this helps.

    #2217
    PiotrPiotr
    Keymaster

    Hi Sanket,
    This is completely different issue – can you use OnBrowserClosed callback and simply resume your audio there?

    #2218
    SanketSanket
    Participant

    Well, I tried that, but the in-game audio is not paused/stopped, its muted maybe because the InAppBrowser video player takes over the audio on playing a video. Even if I increase the volume it does not change anything.

    But if I press the home button in android, and open the app again, I am able to hear back the in-game sound.

    Now, this was the actual issue that I raised here. I thought because I was playing a video in the IAB, the instance might not be closing properly on browser close and this might be causing the in-game audio to not resume.

    Normally, when I open the IAB browser, the in-game audio is playing no matter which web page I load, but the moment I play a video, it does not return to the in-game audio on browser close and no sounds are not heard on the speaker (not even button clicks) after that.

    • This reply was modified 1 year, 1 month ago by SanketSanket. Reason: typo
    #2225
    enupgames
    Participant

    Thanks. Both files worked perfect for me.
    I couldn’t actually test the Android,
    since I never get that full screen scenario like in iOS.

    Sorry Sanket. I must’ve misunderstood your initial request and
    ended up inadvertently hijacking your thread. 🙂

Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.