RenderHeads / UnityPlugin-AVProVideo

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

Only first video outputs audio through Unity on Android with AVPro-v3 #1836

Closed Last8Exile closed 3 weeks ago

Last8Exile commented 2 months ago

Describe the issue We using AudioMode: Unity. First video play audio through Unity. All further videos play audio bypassing Unity.

We use additional sound processing on Unity side (spatialization, 5.1 to stereo mixing, gloabal volume control through mixer groups) and rely on AudioMode: Unity working correctly. Workaround would be helpfil.

Your Setup (please complete the following information):

To Reproduce

  1. Open attached project (link in email)
  2. Build and run application (Development Build) on Android.
  3. Connect Unity Profiler with Audio module to application running on android.
  4. Enter path to any local video with audio ( /storage/emulated/0/.../someVideo.mp4 ) in InputField at the Top.
  5. Tap Open button at Top Right
  6. Tap Play button at Bot Left (or at screen Center)
  7. Observe audio is played through Unity 6.1. Green spectrum visualisation on Bot Right is not flat 6.2. VU Level of Global mixer group is above -100 db
  8. Tap Open button again
  9. Tap Play button again
  10. Observe audio is played bypasing Unity 9.1. Green spectrum visualisation on Bot Right is flat 9.2. VU Level of Global mixer group is below -100 db (it needs several seconds to drop)
Last8Exile commented 2 months ago

Workaround: creating new player each time opening video fixes the issue. Simple copy and destroy approach:

MediaPlayer _player;
...
var oldPlayer = _player;
_player = Instantiate(oldPlayer);
SetReferencesAndResubscribeToEventsInExternalComponents(_player);
Destroy(oldPlayer.gameObject);
Chris-RH commented 2 months ago

Thanks, we have received your email

Last8Exile commented 2 months ago

Workaround with recreating players somehow randomly freezes main thread completly.

It freezes somewhere near executing MediaPlayer.OnDestroy. If I don't destoy previous MediaPlayer instances and only disable them - there is no freeze. I can't reproduce it on Demo project and ran out of time to investigate.

Ste-RH commented 3 weeks ago

A fix for this is offered in v3.0.2 (which we are hoping to release today)

Chris-RH commented 3 weeks ago

AVPro Video version 3.0.2 has been released. Please let us know if it has not fixed your issue.