RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 29 forks source link

[Android] When the media player starts playing, any other sound disappears #2076

Open IgorKubyshkin opened 8 hours ago

IgorKubyshkin commented 8 hours ago

Unity version

2022.3.32f1

Unity editor platform

Windows

AVPro Video edition

Core

AVPro Video version

3.1.2

Device hardware

realme 8i

Which Android OS version are you using?

13

Unity Graphics API

OpenGLES 3, Vulkan

Video API

MediaPlayer

Texture format

BGRA

Audio output

Unity

Any other Media Player component configuration required to reproduce the issue.

No response

Which output component(s) are you using?

No response

Any other component configuration required to reproduce the issue.

No response

The issue

When the media player starts playing a video, any other sound (except directly video sound) disappears and does not even return after the video is closed. If you minimize/expand the application (pause/unpause), the sound will be restored. There was no such problem in the previous version (3.0.8) of the plugin I used. When playing the video again after the application has returned from background mode, the sound no longer disappears, i.e. it starts working as expected.

Media information

No response

Logcat output

No response

Chris-RH commented 8 hours ago

We've done a quick test and can't reproduce this.

  1. What do you mean by "any other sound"? Do you mean other sounds coming from your app, or do you mean other sounds that are also playing on your phone? Or something else?
  2. Have you tested it on any other devices, and if so, does the error still occur?
  3. Which audio output are you using? System Direct/Unity/FB360, and does it occur in the others?
  4. Does this also occur when Video API is set to 'Exoplayer'?
  5. Can it be reproduced in a new project running only AVPro Video demo scenes?
  6. Can you provide a step by step of how to reproduce this please?
IgorKubyshkin commented 7 hours ago
  1. I mean other sounds coming from my app (speech or sound effects).
  2. I've tested on iOS devices and it is not reproduced on my work iOS devices, only android. I have another android device and can test on it too.
  3. I use Unity. But I tried System Direct with no result. The same problem still happened
  4. If I use Exoplayer, when I try to play any video the app will crash :) That's why I use Media Player. It's happened to me on other plugin version too.
  5. Ok, I will try
  6. I just play any video in my app and it always happen when video starts playing
Ste-RH commented 6 hours ago
Please do not post up projects. Instead, email them to unitysupport@renderheads.com
IgorKubyshkin commented 6 hours ago

I've just sent a link to unitysupport@renderheads.com

IgorKubyshkin commented 6 hours ago

It's test project with one scene. I run this scene with audio playing in the loop. When I run it on android device, the audio doesn't play until I pause/unpause the app. I even doesn't click the test button Open Media

IgorKubyshkin commented 6 hours ago

When I try to open media, click the button, the app crash. It's weird too, because there is no extra code there. Only the Open Media method

Ste-RH commented 6 hours ago

The test project you sent uses v3.1.0, not 3.1.2 as you initially stated.

IgorKubyshkin commented 6 hours ago

Android - 3.1.2 Helper.cs public const string Windows = "3.1.0"; public const string WinRT = "3.1.0"; public const string Android = "3.1.2"; public const string Apple = "3.1.1";

Ste-RH commented 6 hours ago

You are right. My bad.

IgorKubyshkin commented 6 hours ago

To be honest, I commented on line 56 - GradleMain Template( path ); in PreProcessBuild_Android. Because media3-exoplayer-work manager (in particular android.work work-runtime 2.8.1) conflicts with other plugins in my project. But if you uncomment, the problem with sound remains. But crash is gone).

Ste-RH commented 6 hours ago

In 'OnPostGenerateGradleAndroidProject( string path )'

...why is the call to 'GradleMainTemplate( path );' commented out? That is why ExoPlayer does not work.

I have reproduced it in your project/scene. I will look into why, but as could not reproduce this in our Demo_MediaPlayer scene...I am wondering if it is something specific to your scene/project.

IgorKubyshkin commented 6 hours ago

I've just set video API to Exo Player and rebuilt. The same happens - no audio on start, but after pause/resume the app, it appears

IgorKubyshkin commented 5 hours ago

I think "Mute Other Audio Sources" flag have an effect on this problem. But old version (3.0.8) works fine with this flag

IgorKubyshkin commented 5 hours ago

I wonder why this is happening

Ste-RH commented 5 hours ago

Yup, just found the same looking at the differences. Disable it and it works fine.

We have made no changes in the MediaPlayer API path regarding this, so I am reluctant to call this an AVPro Video issue. I am going to try v3.0.8 myself to verify.

image

IgorKubyshkin commented 5 hours ago

In my real project all fine with sound, until the Media player initialized. When I try to start any video in v3.1.2, the sound will go. When I roll back to 3.0.8, the sound appears

Ste-RH commented 5 hours ago

Verified that audio still works with that flag enabled in 3.0.8 + 3.0.9 + 3.0.10 + 3.0.11. It fails in 3.1.0 - which is when we updated to media3 v1.4.1 - and 3.1.1 + 3.1.2.

There is not much I can think of by way of reason as media3 is not even being initialised...and in your project you have completely removed the dependencies with the script change.

IgorKubyshkin commented 5 hours ago

How can I get 3.0.11 as temporary solution? I think 3.0.8 has some issues I want to be resolved

Ste-RH commented 5 hours ago

If you email your Unity PDF invoice over to unitysupport@renderheads.com we can send send over 3.0.11

IgorKubyshkin commented 5 hours ago

1 I noticed crashes with 3.0.8. I think it looks like https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1998

Ste-RH commented 1 hour ago

It looks like this issue has come about due to us adding in code to gain focus from the audio manager. We need to do this to catch when the OS takes focus for such things as incoming calls, alarms, etc. When this happens, we action a pause on all videos. Then, when focus is regained, we play those videos that were paused when focus was relinquished earlier.

Currently, we have no solution to satisfy both cases.