Caching streamed movie on iPhone - ios

In a few days I'm supposed to start working on a new app and one of the requirements seems a bit odd to me. User will be able to watch streamed videos that my client also has on his site. Problem is, app has to save it and later, when user is offline, he should have the option to watch it again. Any ideas how am I supposed to save that (streamed) movie to memory?
Edit: The movie can even be 1 hour long.

Related

Why would AVPlayer observedBitrate (and bitrate play) seriously degrade on second playback in iOS 13?

I have an app that uses AVPlayer to play live streams and on-demand video. That in-house app (and recent in-house update) plays video beautifully in all sorts of conditions. Until a user in the company updated to iOS 13.
The same app run under iOS 12 from the same location will work perfect as before.
Now, after a reboot of the phone the first video played will play perfect and if it is a live stream will run for an indefinite amount of time without trouble. The second video played will always play audio only or fail depending on the bit rates available for the video. Even the exact same video.
Quiting and restarting the app makes no difference in the results. Restarting the phone WILL fix it for the next video played.
What appears to be happening is that on the first play, observedBitrate in the event log is correct and the correct bit rate stream is played. The second playback shows observedBitrate starting out an order of magnitude less and no reasonable amount of time sees that rate change significantly.
If the connection is an order of magnitude better than necessary (evidently that is true for most of these users including myself pre-Network Link Conditioner testing), then everything appears to work normally and life is good. What is even stranger, is that on these higher quality connections I don't see the same observedBitrate drop. Also, it appears that video served up from a different ip (but not different domains from same ip) will work once and then fail the second time as if some kind of connection bit rate cache is being used? These last two observations have not been repeated enough to be cast in stone but have been observed more than once.
I've scoured the iOS 13 release notes in hopes that I'm missing some change or need for a new key but nothing strikes me as relevant.
Any ideas appreciated!!!
A very similar question was posted earlier this year Video playback issues only on iOS 13 with AVPlayerViewController and AVPlayer when using HLS video. The unaccepted answer in that question does not apply here (and may not apply there either for all we know). I do wait for StreamPlayerItemStatusObserverContext to change to AVPlayerStatusReadyToPlay.

4 hour browse watch, cert performance and multi app test

Recently observing that 4 hour browse to watch, multi app performance and cert performance tests are only navigating and not playing any content. This was working on same code till last week. We tried few things and find out that if brand name is not passed then most of the time test behaves as expected. Has anything changed on YouTube backend?
For the questions about YouTube, please reach out to your Technical Account Manager at YouTube.

Should I use local videos or youtube videos

I'm developing an iOS app that is going to use plenty of videos. The app in summary is a quiz app, where after each question it shows your a video relevant to that question.
my question is, should I use local videos or just referencing youtube links to show the videos? keep in mind that all of the videos that I am going to show are youtube videos that I have already downloaded and added to the app bundle.
what are the benefits and downfalls of each? in terms of app development and user interaction?
Most of the things that you need to consider are
Size of the app with all videos inside. If you add everything in the
bundle than the size of the application will be big and some people
will reject to download it especially if they are not in wifi
network
Do you need these videos if you don't have a network? If yes, you
have two options, the first one to add everything in the bundle and the second one to download them inside the app when the app starts.
What about the speed? Is it okay to wait for the stream or you need instant play?
I think these are the 3 main points for this. (Size, Offline, Speed)
If you have everything in the bundle Offline support and speed of playing will be okay. But for sure you can have a problem with the size. If everything is in youtube the size will be fine but then you will have problems with the speed and the offline mode.

Can HTML5 in the browser play continuous audio on iOS lock screen?

I have been trying to track this down and there doesn't seem to be a consistent answer. If I have a website that tries to play multiple songs in a row (think playlist) using the HTML 5 audio element, can it continue to work on the iOS lock screen?
For some background, this answer seems to indicate it may be possible. But then this article suggests it is not.
I tried following the closest example of what Apple recommends, as found here, to replicate this. I am using plain, vanilla javascript and HTML, nothing fancy. I copied their example exactly and just substituted the audio tag for the video one, picking two random mp3 songs. All it does is wait for one song to end, then switch the src, load, and play the next track.
When I hit Play on the website, I then lock the iPhone. The first song will play, then stop. It does not continue to the next song.
If the website is open to the page, it will properly transition to the next song. On Android, it will continue to the next song even if the phone is locked.
I tried this with iOS 11 and 12. Neither worked. I have read many differing answers about how javascript is stopped when the website isn't in the foreground, and how iOS requires user interaction to play audio (even going from one song to the next). So it doesn't seem like this would work. But then other answers out there seem to indicate this is possible.
Is there a definitive yes or no? Am I doing something wrong here? Or is it just not possible?
There are multiple issues, which is causing some of the confusion.
First track plays, second does not due to user permission
If the first track was started with user permission, then the only way you can switch to a new track via script is with Apple's recommendation. Handle the ended event and swap in a new src, and call .play() before the callback completes. Otherwise, your code will not have permission to start the new audio.
Cannot get to ended event due to time-constrained source (#t=5,10)
Say you have a 30-second audio file and you tell the browser to only load seconds 5 through 10, via something like #t=5,10 at the end of the URL. When you reach 10, a paused event will fire, not ended. Therefore, it isn't possible to go on to the next track normally, as this event is not "blessed" by Apple to count as a relay of the previous user interaction.
I got around this by having my JavaScript check the currentTime repeatedly, and when it crossed a threshold, seek it to the duration (end) of the file myself. This allows ended to fire normally.
iOS doesn't allow scripts to run after the screen is locked or other apps are in use
This one is a real problem to debug, since it doesn't turn up in any of the simulators. In any case, you're right, your JavaScript is going to get suspended so even if you follow Apple's recommendations, you're out of luck. Or, are you?
A hack... set up a ScriptProcessorNode on a Web Audio context. Set the buffer size to like 512 samples or something. Then, on script process, force a timeupdate event for your Audio Element. This keeps your JavaScript there ticking away. ScriptProcessorNode has to have special privileges here, by its nature.
Apple: If you read this, please fix your browser. It would be great if we didn't have to hack around things to make something as simple as an audio playlist to work. Other browsers don't have nearly this level of problems.

Background file upload in Blackberry WebWorks

I'm writing a Blackberry Z10 app for use in onsite events where we take photos or short videos of attendees and the photos are available immediately on a website. We take the photo, enter a message to be displayed with it and the photo gets uploaded right then. We initially used blackberry.io.filetransfer.upload but the videos could be up to 30MB so would have a long wait time, so we switched to an XHR transfer where we could have a progress bar so at least the app user would have something to look at.
We've found that sometimes they're in areas with low connectivity, so would like to just copy the file to a folder that is watched by a background process and anything deposited there gets uploaded to the server. How can we get an app functioning basically as a service, doing file transfers even when minimized?

Resources