googleads / videojs-ima

IMA SDK Plugin for Video.js
Apache License 2.0
445 stars 285 forks source link

Preroll and main video play simultaneously on Android device, when main video is of type m3u8 #1098

Open tbourigault opened 1 year ago

tbourigault commented 1 year ago

When the video is started as soon as possible on an Android device and the main video is of type m3u8, the preroll and main video will start playing both at the same time, instead of playing the preroll first and then the main video. The preroll only is visible but we can hear the audio of the main video in the background.

I have made a copy of the simple example changing only the main video from a mp4 to a m3u8

original (mp4 no bug) https://googleads.github.io/videojs-ima/examples/simple/

modified version (m3u8 bug) https://tbourigault.github.io/IMA-SDK-Plugin-VideoJS-Simple-M3U8.html

Steps to reproduce:

Expected behavior: The preroll ad should play first, followed by the main video.

Actual behavior: Both the preroll ad and main video start playing at the same time. The preroll only is visible but we can hear the audio of the main video in the background.

Environment details: Bug was reproduced on multiple android devices, different m3u8 files and versions of videoJS 7 & 8

one example: Operating system: Android 6.0.1 Browser: Google Chrome (Version 106.0.5249) Video player: video.js (Version 7.18.1) with the videojs-ima plugin (Version 2.0)

Kiro705 commented 1 year ago

Hello @tbourigault

Android 6.0.1 is marked as no longer maintained. If you are able to develop a fix using using your device, I can take a look at the pull-request. Otherwise, the plugin may not be able to support that version of Android.

I tested the sample you shared on the following device and saw playback happen as expected.

Thank you, Jackson IMA SDK team

tbourigault commented 1 year ago

Hello @Kiro705

I was able to reproduce it on more recent device also 2 person on my team were also able to reproduce the bug on:

Thank you

toperharley commented 1 year ago

I have the same issue, really weird to hear the audio of the 2 videos at the same time.

@Kiro705 Any idea about this bug? must be a timing problem?

The important point is to click on the player as soon as the video icon appears, knowing that I can reproduce almost every time. Does not seem to happen when we wait a few seconds or more.

My phone is a Samsung Galaxy A51, Android 13.

floverdevel commented 1 year ago

Hi 👋🏻☺️

On my device: Android 11; ONEPLUS A6013 Build/RKQ1.201217.002

I was able to reproduce the bug using Chrome. Chrome 114.0.5735.60

I was able to reproduce the bug using Edge. Edge 113.0.1774.63

Both audios can be heard simultaneously with this URL: https://tbourigault.github.io/IMA-SDK-Plugin-VideoJS-Simple-M3U8.html

I was unable to reproduce the bug with Firefox. 113.2.0 (Build #2015952075), 88ca8c80c8+ GV: 113.0.2-20230522134052 AS: 97.4.1

Kiro705 commented 1 year ago

Hello all,

I was looking into this issue more, and have been able to reproduce it reliably, when making sure to play the video as soon as possible. Unfortunately, I have not been able to identify a fix for the issue, but will plan to take another look soon. Please let me know if any changes on your end seem to resolve this issue.

Thank you, Jackson IMA SDK team

arifadil739 commented 9 months ago

@floverdevel how are you being able to play mid roll and post roll ads. as i am only being able to play pre-roll ads. can you please share the code. @Kiro705

floverdevel commented 9 months ago

@floverdevel how are you being able to play mid roll and post roll ads. as i am only being able to play pre-roll ads. can you please share the code. @Kiro705

I never tried yet to play mid-roll or post-roll ads.

Jerome-lara commented 4 months ago

Your demo does not work properly on the iPhone user agent, After the pre-roll is played, the video prompts error code 4 The media could not be loaded, either because the server or network failed or because the format is not supported

davlasq commented 3 months ago

Are there any plans of fixing it or workarounds? Maybe downgrade to some particular version?

davlasq commented 3 months ago

Here is my workaround, it doesn't solve the root issue but masks it for users:

let tempVolume;

player.ima.addEventListener(google.ima.AdEvent.Type.STARTED, () => {
  const adVideoEl = player.el().querySelector(".ima-ad-container video[src]");
  tempVolume = player.volume();
  player.volume(0);
  adVideoEl.volume = tempVolume;
});

player.ima.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED, () => {
    player.currentTime(0);
    player.volume(tempVolume);
    player.src(player.src());
    player.play();
  }
);

So basically I mute video on ad start, then unmute and reload on ad end.