Home > Forum > Equivalent of AVFoundation.setRate

Equivalent of AVFoundation.setRate

Oct 07, 2022
Konrad wrote
Hi All!

I need to implement video playback that can synchronize to an audio stream. I implemented the synchronization on iOS with
https://developer.apple.com/documentation/avfoundation/avplayer/1386591-setrate
It allows me play back a file while synchronizing a video clip time excatly to an absolute wall clock time.
I tried to use https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/play-audio-and-video-with-mediaplayer
which is the built-in media player for uwp apps. But this doesn't meet the synchronization requirements that I have.

Would Media Player SDK .Net provide me with the same functionality as iOS' AVFoundation?

Thank you!
Reply
6 Answers
Oct 07, 2022
Roman Miniailov agent wrote
Hi

We can try to add this feature. Do you have some external clock that is used in the "setRate" call?

Thank you.
Oct 07, 2022
Konrad wrote
Hi!

The basic idea is that the video can synchronize perfectly to audio, because this is a music/sound editing application. The audio and video playback happen in the same process but on different threads. On iOS we are also targetting air play devices, which we don't for Windows.

This means that we wouldn't even need this setRate() call for Windows as long as play() immediately plays back the actual time the video is positioned to. This is just not happening for uwp's MediaPlayer , which seems to play back whenever it feels like it so to speak.

Thank you!

Konrad
Oct 07, 2022
Roman Miniailov agent wrote
SDK has an API to preload file and start file without delay on a special method call. I think you can experiment if it's OK for you.

Please check simple player app - https://github.com/visioforge/.Net-SDK-s-samples/tree/master/Media%20Player%20SDK/WinForms/CSharp/Simple%20Video%20Player

Update code:
- Set Play_DelayEnabled property to true before Play/PlayAsync call in your code
- Call Play/PlayAsync
- Call StartDelayed at required moment for a fast playback start
Oct 07, 2022
Konrad wrote
that sounds like it’s exactly what I need. Will give it a try.
Thank you!
Oct 11, 2022
Konrad wrote
I am having some trouble installing the nuget packages. Is my App somehow incompatible? It's a C# UWP App (and communicates to the C++ core with an API). Minimum Windows SDK would be 10.0.18362

NuGet\Install-Package : NU1202: Package VisioForge.DotNet.Core 15.4.31 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x86. Package VisioForge.DotNet.Core 15.4.31 supports:
- monoandroid10.0 (MonoAndroid,Version=v10.0)
- net472 (.NETFramework,Version=v4.7.2)
- net5.0 (.NETCoreApp,Version=v5.0)
- net5.0-windows7.0 (.NETCoreApp,Version=v5.0)
- net6.0 (.NETCoreApp,Version=v6.0)
- net6.0-android31.0 (.NETCoreApp,Version=v6.0)
- net6.0-macos10.14 (.NETCoreApp,Version=v6.0)
- net6.0-windows7.0 (.NETCoreApp,Version=v6.0)
- netcoreapp3.1 (.NETCoreApp,Version=v3.1)
- xamarinmac20 (Xamarin.Mac,Version=v2.0)
Oct 11, 2022
Roman Miniailov agent wrote
Our SDK has WinUI 3 and MAUI support, but not UWP.