Playing Multiple Portions of You Tube Video - youtube

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.

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.

AVQueuePlayer and multiple video playback and time ranges

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.

Is there a YouTube URL format for displaying videos in 1080p?

I know there is this &hd=1 code to start a YouTube video in 720p. Is there a code or trick to add at the end of a YouTube video URL to start in 1080p?
Seems to be working again :)
Using an example:
before:
http://www.youtube.com/watch?v=ecsCrOEYl7c
after:
http://www.youtube.com/watch_popup?v=ecsCrOEYl7c&vq=hd1080
note both:
watch_popup
&vq=hd1080
Other possible values can be found here:
https://developers.google.com/youtube/iframe_api_reference#Playback_quality
You can also change the start time of the player by appending this (to 1 minute and 22 seconds in this example):
&t=1m22s
Some documentation can be found here:
https://developers.google.com/youtube/
It's not possible to set the quality to 1080p only with an URL. Some years ago it was possible by adding &fmt=37 but it doesn't work anymore.
However, if you can use JavaScript the YouTube API will allow you to select the quality.
From documentation:
hd (supported players: AS2)
Values: 0 or 1. Default is 0. Setting to 1 enables HD playback by default. This has no effect on the Chromeless Player. This also has no
effect if an HD version of the video is not available. If you enable
this option, keep in mind that users with a slower connection may have
an sub-optimal experience unless they turn off HD. You should ensure
your player is large enough to display the video in its native
resolution.
AS2 player will be retired in October 2012 and the embed codes on YouTube website load AS3 player by default. To show hd1080 you need to use JavaScript API. The functions are described here.

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