Unity VideoPlayer audio broken after an Agora.io video call - c#

Our application has a scene that does video calling built on agora.io and another scene which plays videos using the Unity VideoPlayer. The problem is that when opening the video player scene after leaving an agora.io call the video playback does not have any audio. This only seems to be a problem on iOS. Android playback is fine.
In xcode when trying play the video we see a lot of the below error repeating while the video plays:
AudioSampleProvider buffer overflow. 4096 sample frames discarded.

Is it possible that you can provide a stripped-down sample project that reproduces this issue?
Otherwise, my recommendation is try a few things:
Do not destroy the Agora engine or disable audio when leaving the Agora scene.
Check if the volume of playback is set to zero (with/without #1 above)
Call the following private API before joining the agora channel:
// Stops the Agora SDK from ending the audio session
mRtcEngine.SetParameters("{\"che.audio.keep.audiosession\": true}");

Related

I can't play video or take photo on Hololens

I am doing 3 things,video record,take photo, play the video.
However, 3 option works on unity but when I build the app for hololens and test it, just video recording is working. I can't take photos and play the video. Basically, I am using these scripts https://learn.microsoft.com/en-us/windows/mixed-reality/develop/unity/locatable-camera-in-unity . The crazy part is Hololens uses flash while taking photos but I can't see my photos in the folder. Also, I can't see the holograms in recorded video.
The issue was Unity Version I was using 2020.3.12f1. I updated to 2020.3.33f1 now video playing is working.

Joining a channel on Agora (Unity/iOS) makes in-game music almost inaudible

I'm trying to integrate Agora voice SDK in a multiplayer project (built using Photon). The level has loads of 3D spacial audio setup and a background music that is properly audible. The moment I join a voice channel, all the in-game audio levels drop drastically. The voice chat volume itself sounds fine however. And this happens only on actual device(iOS), not on Unity editor.
I tried reproducing this issue in the HelloUnity3D sample scene that comes with the SDK. No code change. Simply added an audio source in the scene with a music clip. Seems to be happening there as well.
Is this expected? How do I keep Agora from modifying other audio sources?
Unity version:2020.3.28f1. Agora SDK version: 3.5.0.70
For anyone running into this issue, I was able to fix it by setting the audio profile to AUDIO_SCENARIO_GAME_STREAMING.
mRtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_SPEECH_STANDARD, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING);
The idea is to simply treat the voice chat audio as media volume instead of 'call' volume.
This answer about audio ducking with the Agora SDK is likely what you're after. You might have to add some iOS specific code to your project to achieve it:
https://stackoverflow.com/a/62840934/2156765

How to deal with VLC memory leak of simply playing & stoping with video filter on

I'm seeing a memory leak (10M each time) when I play->stop->play->stop a local mp4 file using both libvlcsharp and the officially released VLC media player(3.0.16) when video filter is applied.
Since I'm having multiple(around 10) VideoView displayed simultaneously in my program, OOM error occurs in like 20 play&stop operations.
I'm using c# and I've tried GC.Collect() in my program, it didn't work.
Anything I can do about this?
FYI: The video filter I've tried: ripple, sharpen, wave. And both libvlcsharp and VLC media player works fine without video filter.
Edit 1:
The vout is dx3d11 and the I'm using VLC media player on windows10.

set playback speed in vlc dot net (winforms)

i am using vlc player in winforms. its working fine, but the problem is that its playing faster. i have videos recorded at 10fps. i think vlcControl is playing at 30fps, that's why video are playing faster. Referred this, but it didn't help. i couldn't find any function like set_play_back_speed function under vlcControl1.VideoI thought vlcControl would automatically figure out fps & play accordingly. if i open the same video from vlc media player installed on my windows pc, it plays at proper rate.
any clue how to fix this?
P.S: if i open any video recorded at 29.97fps, vlcControl in winforms is playing it at proper speed.
Well, there's no function to set FPS to video thru Vlc.DotNet and I am not sure are you using WinForms or WPF application, but best I can help is probably, if you would play with rate settings as in transpone video.
It's found at vlcControl1.rate (which is float value default is 1.00), if you have 30fps and only want 10fps well, you could try to set:
vlcControl1.rate = (int)(33 / 100);
Which then would decrease video and audio transpone to 10fps from 30fps (assuming 1.00 = 30fps).

System.Media.SoundPlayer.Play() freezes GUI

I am trying to implement a simple game in .NET with C#. There is a ball bouncing against objects, and when it bounces I play a sound asynchronously using System.Media:SoundPlayer. The problem is that most of the time (not always) the ball freezes at the time of impact, for as long as the sound plays.
This happens on Windows XP, but not on Windows 7. I use .NET 3.5.
And the weirdest thing is that the problem disappears if I open the application Windows Media Player and play a few seconds of an mp3.
Here's the code where I initialize the SoundPlayer object:
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream s = a.GetManifestResourceStream("Game.Resources.GameBounce.wav");
_playerBounce = new System.Media.SoundPlayer(s);
_playerBounce.Load();
...and when the ball hits an obstacle, this line is called:
_playerBounce.Play();
I have also tried "Attempt #4" in this post:
How to use System.Media.SoundPlayer to asynchronously play a sound file?
Another desperate attempt, based on some advice I found somewhere on the net, was to save the sound stream to a file, that SoundPlayer works better when initialized from a file.
Neither of those attempts worked.
Any ideas?

Categories