UnityPlugin-AVProVideo
UnityPlugin-AVProVideo copied to clipboard
Programmatically changing MediaPlayer.PlatformOptionsIOS.audioMode
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
- In UI, leave the audiomode as the default: system direct
- In code, run
m_MediaPlayer.PlatformOptionsIOS.audioMode = MediaPlayer.OptionsApple.AudioMode.Unity - 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?
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.
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?
That is correct. What's your use case out of interest?
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.)
That makes sense. Why not just use the Unity audio mode for everything?
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.
Yeah, converting the audio output to something Unity can handle does have overheads, especially if it needs resampling.
Support for this will make it into the next release