AVQueuePlayer and multiple video playback and time ranges - ios

Somewhat new to ios programming. Trying to use AVQueuePlayer and playing multiple videos in a list. I have searched and have not seen a relevant example to what I am trying to achieve. This is a question that is probably easily answered if somewhat could point me in the right direction.
What I am trying to do is really play videos in a list in sequential order. So looking at the AVQueuePlayer and AVPlayerItem should seem to fit the bill. I get how you can play multiple videos back to back with this, as most of the examples show how this is done. What I want is to load a player item and to restrict it to a certain time within the file. For example, I would load a video file that is 3 mins long and only want to see the time of 1:20 to 1:35. All the examples I have seen load the entire file. There has to be a way of doing this, and I have not seen a good example of this yet.
I also want the ability for the AvPlayerItems to possibly be the same video file but they are playing different time ranges from the video file. So in essence I am playing video time ranges in a list from any number of video files, but those video files could be the same source file in the list. For example:
A list of video and times to play
(seq Video Time)
1 video 1 0-30 secs ---
2 video 2 45-60 secs ---
3 video 3 120-130 secs ---
4 video 2 3-12 ---
5 video 3 30-40 ---
6 video 1 31 - 40
I have looked at apple developers reference for AvQueuePlayer and have not figured it out yet. I'm sure some of you experienced guys out there have already done this and can point me to some good examples.

After much searching and watching WWDC videos from apple, the answer to my problem is to use AVComposition which will allow you to use multiple video source and compose them into a track that you can play back in whatever order you would like.
A good example is to watch the WWDC 2010 videos in itunes and watch the session named Editing Media with AVFoundation. Within the presentation there is a good example project that they use called AVEditDemo. It will give you the example code that you need to get going.

Related

use one player to play mutliple assets with different durations , and looping

I want to use one player to play multiple audios.
The audio could be stream media, or local.
Audio have different duration.
Audios should be play together and looping, it works just like a mix player.
Media could be insert or remove at any time.
let's say there's two medias. media_a is 15sec long. media_b is 30sec long. Media_A should be play again on 16sec.
And now, I'm using two players to play audio medias, which works fine, but's not good while using airplay.
I found out some ways on website:
Using AVMutableCompositionTracks to create a AVPlayerItem
but media_a is not play again on 16sec.
Use the least common multiple duration for medias and create a big playerItem.
I think is not good, and could not be insert or remove easily.
So, plz help me. Any clue could be appreciated。

How to reduce initial buffering time of AVPlayer to play video?

Hello Friends,
I am working on OTT platform app, I need to play video very smoothly without any delay like Snapchat and instagram as reference. I am using Cloudinary for uploading videos and everything is working good but at first time, AVPlayer takes time of 1-2 second to start video, which is bad thing for Me. Once video play, next time I come on same video it plays smoothly with less delay of max Half second.
As far as I tried to learn through different blogs and stack over flow answers, I get rid this is default AVPlayer Buffering time and it depends of video durations and its fetching video information like title, metadata etc. But I don't have to use these information anywhere.
I tried to set false this property of AVPlayer .automaticallyWaitsToMinimizeStalling = false, but still no luck.
I tried few solutions from StackOverflow posts, but didn't get success
How to reduce iOS AVPlayer start delay
This is demo video Link Which you can try http://res.cloudinary.com/dtzhnffrp/video/upload/v1621013678/1on1/bgasthklqvixukocv6xy.mov
If you can suggest, what I can use for OTT platforms to play video smoothly really grateful to everyone...
Thanks In Advance
Most streaming services use ABR, which creates multiple resolution copies of the video and beaks each into 2-10 second, typicaLLY, chunks.
One benefit of ABR is that to speed up playback start up, the video can start on a lower resolution bit rate and then 'step up' to higher bit rates as it proceeds.
You can often see this on popular streaming services where you will see the video quality is lower when the video starts and improves after a short time.
See here for more on ABRs: https://stackoverflow.com/a/42365034/334402
This requires you to do work on the server side to prepare the video for HLS and DASH streaming, the two most common ABR streaming protocols.
Typically dedicated streaming servers, or a combination of encoders and packagers, are use to prepare and serve the ABR streams. There are also cloud services, for example AWS Media Services or Azure Media Services, which allow on demand streaming models.
You can make the videos smaller either by reducing the dimensions or by compressing it more. Both of these have the effect of lowering startup time - but will sacrifice quality in exchange.
Cloudinary will create ABR versions for you, but the last I checked, you pay for each version created.

Playing Multiple Portions of You Tube Video

I know, we can start playing a youtube video at any minute as Youtube provides the api.
What I want is, I want to play multiple portions of the video. For example in a video I want to play from minute 1 to 2, then again from minute 5 to 10 and again from minute 43 to 54.
Is there an API or tool for doing that.
One thing I thought was creating different videos & put them as a play list, but not sure how faster will it be.
Let me know if there is a way to do this.
Thanks in Advance.
There is the Youtube Player API.
#Getting started shows an example of a video being played for 6 seconds from the beginning before it stops.
#seekTo allows advancement of video playback.
You may also use #loadVideoById to pass in the start time and end time via the object syntax, although this method may require the loading of the same video multiple times.

Skip between multiple files while playing audio in iPhone iOS

For a project I need to handle audio in an iPhone app quite special and hope somebody may point me in the right direction.
Lets say you have a fixed set of up to thirty audio files of the same length (2-3 sec, non-compressed). While a que is playing from one audio file it should be able to update parameters that makes the playing continue from another audio file from the same timestamp the previous audiofile ended playing. If the different audio files is different versions of heavely filtered audio it should be possible to "slide" between them an get the impression that you applied the filter directly. The filtering is at the moment not possible to achive in realtime on an iPhone, therefore the prerendered files.
If A B and C is different audio files I like to be able to:
Play A without interruption:
Start AAAAAAAAAAAAA Stop
Or start play A and continue over in B and then C, initiated while playing
Start AAABBBBBBBBCC Stop
Ideally is should be possible to play two er more ques at the same time. Latency is not that important, but the skipping between files should ideally not produce clicks or delays.
I have looked into using Audio Queue Services (which look like hell to dive into) and sniffed on OpenAl. Could anyone give me a ruff overview and a general direction I can spend the next days burried into?
Try using the iOS Audio Unit API, particularly a mixer unit connected to RemoteIO for audio output.
I managed to do this by using FMOD Designer. FMOD (http://www.fmod.org/) is a sound design framework for game development, that supports iOS development. I made a multitrack-event in FMOD Designer with different layers for each sound clip. Add a parameter in the horizontal bar that lets you controll which sound clip to play in realtime. The trick is to let each soundclip continue over the whole bar and controll which sound that is beeing heard by using a volume effect (0-100%) like in the attached picture. In that way you are ensured that skipping between files follow the same timecode. I have tried this successfully with up to thirty layers, but experienced some double playing. This seemed to dissapear if I cut the number down to fifteen.
It should be possible to use iOS Audio Unit API if you are comfortable with this, but for those of us that like the most simple sollution FMOD is quite good :) Thanks to Ellen S for the sollution tip!
Screenshot of the multitrack-event in FMOD Designer:
https://plus.google.com/photos/106278910734599034045/albums/5723469198734595793?authkey=CNSIkbyYw8PM2wE

loadSound: don't wait for the entire download before play, but not have it start automatically

I am trying to play an MP3 using Actionscript 2. I have the following requirements:
I don't want to wait for the MP3 to load before playing it.
I want to know when enough of the MP3 has downloaded that I can start playing it.
I don't want the MP3 to start playing immediately: I need to control when the play starts.
An example scenario is that I need to start playing a 30-second MP3 exactly 8 seconds from now (at the top of the minute, let's say). Depending on the connection, I may or may not be able to download the entire MP3 by then, but I can almost certainly download enough to start playing without interruption.
The closest way I can see to do this is Sound.loadSound(url, isStreamable). If I pass true for the isStreamable parameter, though, the sound will start playing immediately (docs say: Playback begins when sufficient data has been received to start the decompressor).
I've tried the following:
call mySound.loadSound(mp3Url, true)
mySound.stop(); // so that the auto-play won't happen
set a timer for the top of the minute (8 seconds from now).
In the timer, check the duration of the sound (which continues to get bigger as the file gets loaded). If the duration is < 5 seconds, we don't have enough buffered sound, so generate an error. Otherwise, start playing the sound with s.start(0).
The behavior I see is that the sound doesn't start playing until it's entirely downloaded.
I found your posting (which is a little older now, but... anyway):
there are two options you can use in the Sound-class:
Sound.getBytesTotal
and
Sound.getBytesLoaded
If you compare these two, you can get the amount of bytes loaded at a certain point of time. (See also Sound.onLoad and Sound.onSoundComplete, these two are helpful)
There are also some examples in the Flash help for this.
Greetings,
Draco
I do not believe that this is possible using ActionScript 2. I think you are going to have to either move to AS3 or wrap the MP3 in a SWF.
Even with AS3 you may have to target FP10 in order to use the new sound methods and events that were just added (Sound.extract and Event.SAMPLE_DATA).
In general Sound capabilities in Flash have really lagged until the most recent version of the player.

Resources