UnityPlugin-AVProVideo icon indicating copy to clipboard operation
UnityPlugin-AVProVideo copied to clipboard

Programmatically changing MediaPlayer.PlatformOptionsIOS.audioMode

Open artoonie opened this issue 4 years ago • 7 comments

Describe the issue On iOS, I can set the audio mode in the Unity Editor but not programmatically.

Your Setup (please complete the following information):

  • Unity version: 2020.3.21f1
  • AVPro Video version (number and edition (trial/core/ultra/enterprise)): 2.2.4 core
  • Operating system version: iOS 15
  • Device model: iPhone 12
  • Video specs (resolution, frame-rate, codec, file size): 30fps, 1080p, h264, 600mb

To Reproduce

  1. In UI, leave the audiomode as the default: system direct
  2. In code, run m_MediaPlayer.PlatformOptionsIOS.audioMode = MediaPlayer.OptionsApple.AudioMode.Unity
  3. Notice: the audio mode does not change

I'm not sure if this is expected behavior - if it's not possible to change at certain times, perhaps there should be an error message when it tries to change, plus documentation on when it should change?

artoonie avatar Nov 29 '21 21:11 artoonie

Currently most settings are applied at player creation with just a handful able to be changed dynamically. Audio mode is set when the media is opened though so we could add support for changing it after player creation but prior to calling OpenMedia. It is expensive to set-up for the Unity mode however so we will not allow it to be changed after the media has been opened.

MorrisRH avatar Nov 30 '21 09:11 MorrisRH

Got it - so long-term, we will be able to:

CloseMedia();
UpdatedAudioMode();
OpenMedia();

But today, we need two separate players, one with each audio mode?

artoonie avatar Dec 03 '21 23:12 artoonie

That is correct. What's your use case out of interest?

MorrisRH avatar Dec 04 '21 10:12 MorrisRH

I'm playing back a video, and allowing the user to share pieces of the video rendered within the scene. Sharing the video happens using AVProMovieCapture, which needs to capture audio from Unity, not System Direct. (This is for a Dashcam for your Bike app.)

artoonie avatar Dec 04 '21 17:12 artoonie

That makes sense. Why not just use the Unity audio mode for everything?

MorrisRH avatar Dec 07 '21 11:12 MorrisRH

The audio can be quite choppy under high CPU pressure when doing that- system direct ensures smooth audio playback, at least from what I’ve seen.

So I prefer system direct whenever it can be used.

artoonie avatar Dec 07 '21 11:12 artoonie

Yeah, converting the audio output to something Unity can handle does have overheads, especially if it needs resampling.

MorrisRH avatar Dec 07 '21 11:12 MorrisRH

Support for this will make it into the next release

MorrisRH avatar May 19 '23 12:05 MorrisRH