Is there a way to start buffering video before playing it in Flutter? - flutter

I am trying to make an app that can play multiple videos at once. The goal is to record multiple music voices and then play them together. I am using the video_player plugin and each video has its own player. The problem is that when I start playing, it is not reliable when each player will start. So, I thought if I load the files before start playing this difference could be reduced. But I couldn't figure out how to do it and if it is possible to do. So, is there a way to load those files to reduce this difference? If there is another way to achieve my goal I would be glad to know. Thank you!

I have a similar problem where I want to control the exact moment the video starts playing.
For now, the best way seems to be (assuming you have a _controller constructed already)
await _controller.initialize()
await _controller.play()
await _controller.pause()
After that, the video starts playing almost immediately. For my purposes it’s good enough but if you need to control this down to the millisecond for synchronization purposes it might not cut it.
You might also want to hide the video and mute it during those first calls.

Related

Is it possible to record the audio that comes out of the iPhone?

I am working on an app that allows the user to create a sort of dub. There is an audio file playing, and the user can tap at certain moments to insert sound (kind of like a censor button.) I'm wondering how to go about capturing the final product.
Capturing audio directly from the iPhone seems the easiest route, as the user already hears the finished product as it is made. However, I can't find anything on how to do this. If not possible, are there any suggestions?
The best way would probably be to be using the AV Foundation framework for mixing and then buffering the audio as well as playing it. This would allow for a high abstraction level while guaranteeing both played back and saved audio to be equal.
Apart from that: from a How can I achieve this with minimum code-perspective, without more information about your setup, the question is way too broad and/or opinion-based.
You will have to work with buffers. Don't know right now how it is done in Swift but you can implement it in Obj-C and then bridge it out.
You can refer to this answers here in StackOverflow (They are a bit old)
https://stackoverflow.com/a/11218339/2683201
https://stackoverflow.com/a/10101877/2683201
and a project also exists (but is in Obj-C)
https://github.com/alexbw/novocaine
Mainly the idea for your case would be to have 2 separated buffers and your sound effect.
Then, you will be playing from buffer A (your music) and copying played data into buffer B (final Output) unless you are playing the effect. In wich case you will be copying the effect data into your buffer B.
Other option is to do it offline:
Play your music (or audio) and keep a timer running synced with the elapsed time of your "to be censored audio".
Save the timestamp of when you start and end tapping the censor button (for example).
Overlap buffer A with your effect in those recorded (start-end) timestamps.
Save the buffer as a file (or do whatever you need to do with it)
UPDATE:
You should take a look into the Apple implementation of something like this:
https://developer.apple.com/library/ios/samplecode/AVAEMixerSample/Introduction/Intro.html

Marmalade SDK: is there a way to skip/seek to a part of a video in s3e video play?

I am currently using s3eVideo in the Marmalade SDK to play a video in my project after a button event. I attempted to find a way to implement a slider bar (or something of the like) to go back and forth in the video. I am unsure if this feature is even supported, but I may be wrong. Otherwise, is there a way to open a native video player outside of the app and then play the video that way with the seek feature I need?
Any help would be greatly appreciated.
There doesn't seem to be a way of finding out the length of the video but s3eVideoSetInt (S3E_VIDEO_POSITION, timeInMilliseconds) should do the trick.
I guess it will depend on if the frame index in the file is ok and if the specific platform supports it. Only really did play/stop video in Marmalade so you may have to try using this function while playing, while pause etc and see what works and what errors.

preload sound with soundmanager2

In using soundmanager 2 is there a way to pre-load a track if you know what is the next and previous track that will be played. This will of course quicken the load times for the user in switching between sounds. In the documentation there is a function autoLoad() and load() and I am not sure which one should be used to achieve pre-loading music.
I should also ask when is the best time to start the preload I was thinking during the whileplaying() function.
Any feedback will be greatly appreciated

Play just a part of the sound (both in and out) with OpenAL (iOS)?

I have a recording that has some unuseful voices at the beginning, and at the end.
How can I play just the middle part of the sound?
I have AL_SEC_OFFSET, that is suitable for the entry point, I already use it, but what about the endpoint?
Is there any smart OpenAL settings for this? Hopeso.
Thanks.
There could be a workaround that fires a timer that stops playing before end.
Any simplier?
OpenAL doesn't have built-in support for stopping playback at a specific sample point. A timer is your best bet in this case, even though it will be somewhat inaccurate.
If you want sample-perfect stopping, you could just load the middle part of the audio file into an ALBuffer rather than the entire thing. I have some code which does that here:
https://github.com/kstenerud/ObjectAL-for-iPhone/blob/master/ObjectAL/ObjectAL/Support/OALAudioFile.m#L188

AudioServices (Easy), AVAudioPlayer (Medium), OpenAL (Hard & Overkill?)

I need to play sounds (~5 seconds each) throughout my iphone application. When they're triggered, they need to play immediately.
For the moment I'm using AudioServices and (as you probably know) the first time you play a sound it lags, then every time there after it's perfect. Is there some code available that's clever enough to preload an AudioServices sound (by playing it silently maybe?). I've read adjusting the system volume programmatically will get your app rejected, so that's not an option. Seems AudioServices isn't made for volume correction from what I can see.
I've looked into OpenAL and while feasible seems a little over kill. AVAudioPlayer seems like a little bit of a better option, I'm using that for background music at present. Extending my music player to handle a 'sound board' might be my last resort.
On the topic of OpenAL, does anyone know of a place with a decent (app store friendly) OpenAL wrapper for the iPhone?
Thanks in advance
Finch could be perfect for you. It’s a tiny wrapper around OpenAL with very low latency and simple API. See also all SO questions tagged ‘Finch’.
If you use an AVAudioPlayer, you can call prepareToPlay when you initialize the object to reduce the delay between calling play and having the audio start.