I have the following YouTube embed code, to start a video at a specific time. It used to work a few weeks ago, but it's not working now:
<iframe src="https://www.youtube-nocookie.com/embed/A2_yg19Pu7Y?start=150&version=3&rel=0&modestbranding=1&autoplay=1&loop=1&playlist=A2_yg19Pu7Y" allow="autoplay;accelerometer;clipboard-write;encrypted-media;gyroscope;picture-in-picture" allowfullscreen="" width="1092.8" height="614.7" frameborder="0"></iframe>
The video is supposed to start at 2m 30s, but it starts from the beginning.
Did something change on YouTube side in the past few weeks?
EDIT: It appears, when the embed link contains the playlist parameter (needed for looping the video - https://developers.google.com/youtube/player_parameters#loop), the video does not start from the specified time, it starts from the beginning instead. I need to keep the playlist parameter, but also start the video at the given start time.
To answer your question, I don't think anything changed on YouTube's side.
I went to your link:
https://www.youtube-nocookie.com/embed/A2_yg19Pu7Y?start=150&version=3&rel=0&modestbranding=1&autoplay=1&loop=1&playlist=A2_yg19Pu7Y" allow="autoplay;accelerometer;clipboard-write;encrypted-media;gyroscope;picture-in-picture
And it started at 2:30, like you wanted. That being said, you have a blank space between ...playlist=A2_yg19Pu7Y" and allow="autoplay..., and it looks like your double quotes may be escaping the string. Try deleting that blank space and your video will hopefully work!
Edit: I just did a little research and found that "allow" is an HTML attribute, so the link should probably work as it is at the moment. That being said, if you haven't tested it already, then you should try the whole link as one string for the src= attribute to make sure its working.
Related
I have an AVQueuePlayer that is supposed to play sequentially an array of AVURLAsset representing consecutive fragments of one continuous video.
Whenever a fragment ends and another starts, there is a small glitch that can be well noticed (frame hold for approx 0.2sec and sound gets muted)
I tried researching how to get around that issue but haven't found anything. I tried solving it by having 2 AVQueuePlayer's and switch between both around 0.2sec before the end of every fragment. Issue not solved.
Any idea on how to solve that?
Note: When joining the mp4 fragments together using an mp4 joiner software, the output is a single smooth video without any glitch.
Been through this exactly. You will experience that glitch no matter what you do. Reason being how AVQueuePlayer works. It loads the next item when the previous ends. So if your videos are big, you may also see that blank screen for 2-3 seconds. One solution is what you mentioned, i.e. using two AVQueuePlayer. But as you said its not working for you, and even if you make it work, it will be clumsy.
A better and clean solution is AVMutableComposition. It may look complex at first but its fast and one time task. You create a composition of all of your videos and play it in a simple AVPlayer. And in your case, I assume you just have to play it, so you don't even have to export it.
To know how to use AVMutableComposition, go through this link. It will explain with exact code you need.
As you said, "2 AVQueuePlayers" way still has problem(some sound glitch).
I faced same problem and solved it by using HLS.
You can play local TS files.
At first, make m3u8 and TS files from original movie file.
e.g.
mediafilesegmenter -t 10 sample.mp4
Then, add resource files to iOS device. You can add files from iTunes, add as resource, or make download function and get from your app.
Run a http server, and then pass the local URL to AVPlayerController. I used cocoaHttpServer.
I put simple example here.
https://github.com/satoshi0212/samples/tree/master/TSPlaySample
After playing around 20 short video clips (mp4's) in an HTML5 video control in a UIWebView in iOS, subsequent clips are failing with a MEDIA_ERR_DECODE. The thing is, is that I know the videos are fine, because they were previously played, sometimes even during the same session.
Furthermore, if you wait long enough to request a new video clip, it will usually start working again.
I also know it's not the server because I can do the exact same operation on chrome on my desktop computer and it always works.
Based on my troubleshooting, it seems like the bug is in iOS itself.
Does anyone have any ideas for working around this?
Is there any way to get more information about an media decode error like this in iOS? I tried using Safari's development tool to listen to the http requests but I can't let it record longer than a few seconds before it hits an out of memory error and kills the app.
UPDATE: It also works fine when run in the iOS simulator. It seems the problem only occurs on the iPad itself
After a discussion with Apple Support, the problem has been fixed. The problem has to do with the hardware H264 decoder. Basically, I was never removing the videos from the hardware decoder buffer by never releasing the video resources (which I thought javascript would do itself).
So I was setting the source like this:
$(vid).src = "some source file";
$(vid).play();
... some other stuff happens ...
$(vid).remove();
Doing it this way never removed the video from the decoder buffer, which meant that eventually it not be able to decode any more videos.
To fix this, this is how you must remove the video from the DOM:
$(vid).src = "some source file";
$(vid).play();
... some other stuff happens ...
$(vid).remove();
$(vid).src = "";
$(vid).load();
Now I realize that this doesn't make a ton of sense because after .remove() is called, I would have assumed that the control has been removed from the DOM and any garbage collection would do the rest automatically. However, it doesn't work like that. I hope this helps other people.
It is not iOS specific. I can reproduce in Chrome web browser.
NB : If the video has multiple sources, you must reset src attribute for each source.
var sources = $(vid).getElementsByTagName('source');
for (var index = 0; index < sources.length; index++)
{
sources[index].src = "";
}
$(vid).load();
jugg1es answer above is correct, but the problem still exists if you're trying to use HLS video. When I tried to use his solution with jquery-3.1.1.js I hit an error in jquery's load() method. Not using jquery actually worked for me:
document.getElementById(id).src = "";
document.getElementById(id).load();
Thanks jugg1es you saved my project.
I am trying to start playing a video file while still being downloaded(i.e. I am trying to emulate buffering.)
My approach:
I maintain a file handle to the video file created. In – connection:didReceiveData: implementation I append the data received to the video file(I ensure this with seekToEndOfFile). Once the total data received passes a threshold value, I start playing the file. Meanwhile I expect – connection:didReceiveData: to keep working the same way as before by appending the data coming in. This approach is inspired from the following post.
http://lists.apple.com/archives/cocoa-dev/2011/Jun/msg00844.html
Result:
Though the author of post above seems to be able to play at least part of the file, in my case the MoviePlayerViewController just shows up on the screen and goes away as though there are no contents in the file.
The code works perfectly fine if I write the whole video data to the file and play once the connection finishes loading.
Has anyone attempted this kind of approach before and succeeded at it?
Experimented a lot. Don't think it's possible without having a dedicated streaming server https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/StreamingMediaGuide/Introduction/Introduction.html
Hence went with a different approach.
I have a website that plays back videos using the html5 video tag and the javascript api for the video tag, and also plays back youtube videos using the youtube javascript api. I notice a bug on some browsers for youtube videos - when I seek to a certain point and play (all this in response to a user click on a button) the video doesn't seek. It plays from the beginning.
This is not a problem for videos played back with the html5 video tag. I think the reason that it is not a problem is that I use the "preload" option with that tag, which means that the video is mostly loaded and buffered before the user even clicks the button that does the SEEK.
So to get it to work with youtube, I need an equivalent of a "preload", or, perhaps I can make autoplay true, but then pause the video after a millisecond, just to get the buffering started.
Is there some solution to this that I don't know about?
Which function are you using to do the seeking? It sounds a little like you might be using "playVideoAt()" -- with that function, if you specify a time beyond what is loaded, then it is expected behavior for it to start to play at the beginning. If, however, you're using the "seekTo()" method, then it shouldn't be doing that ... seekTo() should allow playing beyond what is loaded without a problem.
Another possibility would be to see if the "allowSeekAhead" parameter (to the "seekTo()" method) is being set or not.
I am having problem with HTML 5 video on iPad.It is working in all major browsers.I have hosted a video on the Apache tomcat and try in the ipad.It works well.But I need to play a URL which is having matrix parameters in iPad.
It would be great if somebody can tell me,how can I host a video in the Apache tomcat and add some matrix parameters to it.It will work,If we add some junk query parameters with the URL.If we add matrix parameters in the same way,it will not work.
is there any specification says that,the matrix parameters will not work on iPad ?
This question is a little old, but our research may help someone else who chances across this.
We spent some time diagnosing problems playing back content on iOS/QuickTime using URLs with matrix parameters. Specifically we were trying to play HLS content using URLs of the form 'http://myserver.mydomain.com/path;a=b.m3u8'
The video would play fine the first time, then fail the second (and every other) time. If the matrix parameters weren't present, the video played fine every time.
Eventually we concluded it was an issue with iOS/QuickTime writing bad cache entries. So the first time the server returned content, this was as cache miss on iOS/QuickTime so it played fine. The next time, the server returned a 304 (not modified -- i.e. a cache hit), iOS/QuickTime tried to pull it from its cache, this failed so the video wouldn't play.
Our solution was to prevent client caching by setting the Cache-Control header to no-cache. Another solution would be to not use matrix parameters.
Note that in terms of HLS, this bug only seemed to occur with the first m3u8 file loaded -- m3u8 URLs listed in the first m3u8 that contained matrix parameters seemed to play fine.