Playing YouTube video with start and end time using YouTube API - youtube

I'm trying to figure out how to set a custom start and end time for an embedded YouTube video shown below:
https://youtube.googleapis.com/v/BmOpD46eZoA%26start=36%26end=65
However the above link is not working properly in the Safari browser. Can anyone suggest how to make this work for the Safari browser?

Your problem is on the encoding of "?"and "&".
https://www.youtube.com/v/BmOpD46eZoA?start=36&end=65
or
http://www.youtube.com/embed/BmOpD46eZoA?start=36&end=65
simply works fine.

You should try
https://www.youtube.com/embed/-ZWGpOSS6T0?start=130&end=144&version=3
First thing you have to do is of course get the specific time you want your embedded video to start and the specific time you want it to end at. Then convert them into seconds. Let’s say you want to embed only the part of the video starting from 02:16 up to 02:58.
In seconds, your start time would be ( 2 * 60 ) + 16 = 136 and your end time would be ( 2 * 60 ) + 58 = 178.
Next, grab the embed code from the Youtube video, and append the following parameters to the video URL in the embed code:
?start=[your_start_time]&end=[your_end_time]&version=3
Replace [your_start_time] and [your_end_time] with your actual start and end times in seconds so that your embed code would look like this:
Read more here, How to embed or link to a specific part of a YouTube video

Try this link, it must be helpful
https://www.youtube.com/v/BmOpD46eZoA?start=36&end=65&version=3

Related

liquid soap backup playlist

I am using liquidspoap for a community radio station. when silence is detected, liquidsoap starts playing a playlist.
My issue is that, if liquid soap detects silence then it starts the backup pls, then goes back to normal once sound comes back, then the next time it detects silence, it plays the backup playlist, but this time it continues playing from where it was left last time. I just want the playlist to play from the beginning each time? any ideas please, my script is below
#!/home/ubuntu/.opam/system/bin/liquidsoap
set("log.file",false)
set("log.stdout",true)
set("log.level",3)
# myplaylist
myplaylist = playlist("~/backup_playlist/playlist/Emergency-list.m3u",mode="normal")
backup_playlist = audio_to_stereo(myplaylist)
blank = once(single("~/blank_7_s.mp3"))
#Live local talk stream
live_local = input.http("http://test.com:8382/main.mp3")
#Live remote talk stream
live_remote=input.harbor("live_remote",port=8383,password="test",buffer=2.0)
# Talk over stream using microphone mount.
mic=input.harbor("mic",port=8383,password="test",buffer=2.0)
# If something goes wrong, we'll play this
security = single("~/backup_playlist/test.mp3")
radio = fallback(track_sensitive=false, [strip_blank(max_blank=120.,live_remote), strip_blank(max_blank=120.,live_local), backup_playlist , security])
radio = smooth_add(delay=0.65, p=0.15, normal=radio, special=strip_blank(max_blank=2.,mic))
# Stream it out
output.icecast(%mp3(bitrate=64), host="localhost", port=8382, password="test", mount="listen.mp3", genre="Talk", description="test Station Australia", $
If you do not need to have a playlist, an easy way would be to have an array of songs, and when you fallback, you just pick a random song from that array and it will start from the beginning. Note, I do not know how to do this or if it would work, as I am not familiar with liquidsoap, and this is more of a workaround than a solution. I will work on finding a better solution, but I hope this helps for now!

Streaming .mp3 with AVURLAsset + AVPlayerItem + AVPLayer

I have an URL. It looks like this:
https://content.stage.someCompany.net/deliveries/artistNameHere/songNameHere-128.mp3?Expires=someNumberHere&Signature=someReallyReallyReallyLongStringHere&Key-Pair-Id=someIdHere
Let me break it down in pieces:
https://content.stage.someCompany.net/deliveries/artistNameHere/songNameHere-128.mp3
?Expires=someNumberHere
&Signature=someReallyReallyReallyLongStringHere
&Key-Pair-Id=someIdHere
As you can see, it's just a glorified .mp3 restricted to 128 kbps, with some security stuff at the end.
If I load it in Safari on my Mac, it will play. If I pass it to an AVPlayer constructor in my iOS app, it will play as well.
If, however, I use it to create an AVURLAsset, it reports that .isPlayable is false. If I stubbornly persist in further creating an AVPlayerItem based on that asset, it will report AVPlayerItemStatusFailed.
Needless to say, in these conditions my AVURLAsset + AVPlayerItem + AVPLayer infrastructure, which culminates in player.play(), actually plays no music.
However, it does successfully play if I substitute other URLs, like Apple's own https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
or
(some random .mp3 from another stackoverflow topic) http://podcast.cbc.ca/mp3/podcasts/asithappens_20160907_50906.mp3
The differences that I see: Apple's url is in fact a "playlist" of some sort, while the second one in a plain, "civilised" .mp3. No more security mambo-jumbo at the end of the link.
Why won't my url play? Do I need to do something specific with the security stuff? Right now, I'm just naively "hey, AVURLAsset...here's my (entire) URL...do your stuff with it..."
Found it.
The links that I receive are valid only once. Apparently that's why "the security" is in place at the end of them.
Testing one in Safari and "seeing that it works" invalidates it. Subsequently, trying the same one in the app results is .isPlayable = false.
Simply requesting & using directly in the app results in .isPlayable = true.
So AVURLAsset + AVPlayerItem + AVPLayer are working just fine. I was just a bloody fool.

PrimeFaces p:media tag for using youtube

I have used PrimeFaces for playing a youtube video from url.But there is a problem in this tag.Some of the youtube links are playing but some of them are not playing.For example;
this video is playing but this video is not playing.Here is the code;
< p : media value = "http://www.youtube.com/watch?v=mqOo7cYCBAo" width="600"
height="400"
player="flash"/>
you need to check the link. The video link which it plays has some modifications. Its not exactly the same as the one you're trying to play.
https://www.youtube.com/v/KZnUr8lcqjo
https://www.youtube.com/watch?v=mqOo7cYCBAo
Observe the strings after .com
You need to replace the string in proper format to make it play.

AVMutableMetadataItem's time & duration INVALID after reading

I have a question.
Recently I needed to add custom tags for recorded video. Local video on device not a streamed video. The task is to add some event specific tags in video, position of which could be set by pressing forward/backward like buttons like in any player.
It is not important whether the movie file will be mov file or mp4 format.
I searched on forum, found several samples how to add metadata using AVExportSession & it worked.
Although, when I tried to add metadata using AVAssetWriter. I wasn't able to append attributes to video.
What I do not understand is that after adding attribute, returned (time & duration) properties are always invalid.
For instance let's say I have a video with duration 2 seconds.
I have tried different key spaces. I am not able to write keys' from ID3 space.
IS ID3 used for stream video? (as far as I understood ID3 metadata of .mp3). Therefore, I was not able to write it into MPEG-4 file
I also used QuickTimeUserData & ISOUserData but again results are the same.
Here is an example
AVMutableMetadataItem *item2 = [AVMutableMetadataItem new];
item2.keySpace = AVMetadataKeySpaceiTunes;
item2.key = AVMetadataiTunesMetadataKeyUserComment;
item2.value = #"One two three";
item2.duration =CMTimeMakeWithSeconds(1, 1);
item2.time = CMTimeMakeWithSeconds(0, 1);
After reading I got the following:
AVMutableMetadataItem: 0xa4301f0, keySpace=itsk, key=\U00a9cmt, commonKey=(null), locale= (null), value=One two three, time={INVALID}, duration={INVALID}, extras={\n dataType = 1;\n}
I would like to use time & duration properties for metadata instead of writing custom data and processing it after that.
Ideally it would be great to append array of items with time = t1, duration = d1, .... (tn,dn).
Does anyone know how to accomplish that?
I've ended with a solution adding chapters to a video file instead of using metadata.
I looked at available libraries, took mpv4lib.
The library currently is not compiled for iOS, therefore, I ported the source project into static library for iOS platform.
That library allows to add custom "atoms" to mp4 file, and one of them is Quick Time text track, containing chapters.
I do similar with that post
The library is located here.

ROKU-Using urlTransfer to Call Script File

Not sure how Roku and Brightscript actually works. I need to call a script file just before the channel starts to stream. The script file will convert the stream on fly. I asked how to do this in Roku forum and was told to use urlTransfer. Well, the sdk gives little help that I can see when explaining how to. I ran across this post on stackoverflow:
How to make api request to some server in roku
It gives a good example which I think I understand. My confusion comes in where and how the function is called. It has to happen right before the video url is called so the conversion can start.
Any advice appreciated.
If you are using roVideoPlayer then just before you call the play function and if you are using roVideoScreen then just before the show function.
Example snippet:
roVideoPlayer
player=CreateObject('roVideoPlayer')
* Your code to add content for the player
* Your call to script
player.play()
roVideoScreen
player=CreateObject('roVideoScreen')
* Your code to add content for the player
* Your call to script
player.show()
Hope this helps

Resources