Downloading Video on iPhone using SDK - iphone

I would like to develop such iphone application that provides functionality to download viedo. i am doing some as below
1) Loading HTML content on web view
2) The loaded html content contains the video link (i.e http://test.com/test.mp4")
3) When i click on that it will play the video in native player.
4) but i would like to prevent this thing and start downloading video from that URL
for example, if i click on link it should not open native video player, it should start downloading from that url and store somewhere on iphone (i.e document directory)
is there any solution for same?
Thanks
Vivek

You should use UIWebViewDelegates webView:shouldStartLoadWithRequest:navigationType: method to decide whether or not to load a URL.
You can check the request, and perform some logic, for instance, checking if the URL's suffix is 'mp4' and if so, do something other than load the request in the webview.
You can intercept the mp4 urls, and then hand them off to another method in your controller that will kick off an NSURLRequest to download the video data.
Once you have the video data, you can write it to the documents directory.

Related

How to get to play an audio file in browser itself rather than downloading from a onedrive shared folder link?

I'm working on a flutter application which uses the shared data from onedrive to play in the app but I'm having trouble getting the m4a file.
For instance, This is a onedrive link: https://1drv.ms/u/s!Aicuq23aphFzb_KQvr0anumY9Jk?e=NQZfXl. Now, I converted it to an api as given in here and I got this URL.
When I browse children.#content.downloadUrl I see a link which is a download link but I want a link with m4a file that will play in the browser itself. How am I suppose to achieve that ?
You will need an audio playing service in your app which can take an URL and play it for you handling all the internals like downloading, buffering etc.
Checkout this package: audio_service

Decoding facebook's blob video url

I found blob:https://www.facebook.com/c7e5a634-2343-4464-a03e-4a1987301ca1 video source on Facebook's private group and I really can't download the video by entering the url nor am I able to decode. Is there any way to decode this?
<video height="274" width="476" preload="auto" style="" class="_ox1 _21y0 _1_d1" data-video-width="476" data-video-height="274" data-original-aspect-ratio="1.7387058423913" id="u_0_27" src="blob:https://www.facebook.com/dc89feae-5b46-4103-8ee9-da7d7630ca94"></video>
This method will get the video and its audio AS SEPARATE FILES. The downloaded video will have no sound, but you will be able to download its audio file and connect it to the video in some video editing program if you need to.
In Google Chrome, go to Facebook.
Open the Chrome Developer Tools (F12).
Go to the Network tab in the Developer Tools (it's at the top of the Developer Tools window)
Play the video you would like to download on Facebook. Let it play for a few seconds and look at the Network tab during that. Long strings of numbers will appear every couple of seconds.
Right click one of those strings, then go Copy>Copy link address
Paste (CTRL+V) the link you copied somewhere (eg Notepad) and remove "&bytestart=3684046&byteend=3862768" from the end.
So I have a link like:
https://scontent-waw1-1.xx.fbcdn.net/v/t66.18014-6/46772657_738781116188283_6399514850013601801_n.mp4?_nc_cat=107&efg=4yJ7ZW5jb2RlX3RhZyI6ImRhc2hfb2VwX2hxMl9mcmFnXzJfdmlkZW8ifQ%3D%3D&_nc_ht=scontent-waw1-xx&oh=91a5abdd5608768a05fd884773a45802&oe=5C29B042
&bytestart=3684046&byteend=3862768
After you cut the bold part out, the link that points to the full .mp4 or .webm of the video is:
https://scontent-waw1-1.xx.fbcdn.net/v/t66.18014-6/46772657_738781116188283_6399514850013601801_n.mp4?_nc_cat=107&efg=4yJ7ZW5jb2RlX3RhZyI6ImRhc2hfb2VwX2hxMl9mcmFnXzJfdmlkZW8ifQ%3D%3D&_nc_ht=scontent-waw1-xx&oh=91a5abdd5608768a05fd884773a45802&oe=5C29B042
Open the modified link, right click the video inside and select "Save video as..."
Sometimes, when you open the link you may get just the audio of the video instead of the video itself.
That's because Facebook downloads the audio and video separately. Just try repeating steps 5-7 with a different string of numbers till you get it right. Instructions to reduce the chance of accidentally picking an audio link are below.
If you need to download many videos and don't want to guess whether your link points to audio or video, type larger-than: 50k (or more) in the Filter field in the Network tab. You can also click the XHR button in Filters so it doesn't show non-video files like FB images.
You can download an FB video in a chrome browser with no plugins / other software required. (As long as you are logged into FB and have permission to view the video).
open up the video and r.click for Get Video URL (copy it) -if you have the option "Copy URL at current time", use that option instead of "Show video URL"
paste that address into another tab and replace the www with m e.g. https://m.facebook.com/MusicIsMagico/videos/2645908645633407/?t=0
play the video, while it's playing open the dev tools and go to the elements tab
search for mp4 till you find a source address that's inside the
video tags - which will be inside a div that also contains another address with forward slashes and .mp4 in it.
e.g.
https://video.fmel5-1.fna.fbcdn.net/v/t42.9040-2/10000000_1804934796220974_2070197824632389632_n.mp4?_nc_cat=1&efg=eyJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&oh=785f223b80388c820f79b9a49c1dfc39&oe=5B73B10B
copy this source address. When you copy the address, chrome (if that's what you are using) does the html replacement for the ampersand characters. You will need to put them back. So replace the "& a m p ;" (< had to space that so it doesn't get converted here) separators in the address with just & - use notepad find and replace or something ) and paste in another tab. Drop any parts of the URL that have frame sizing etc.. so you address should look like this:
https://video.fmel5-1.fna.fbcdn.net/v/t42.9040-2/10000000_1804934796220974_2070197824632389632_n.mp4?_nc_cat=1&efg=eyJ2ZW5jb2RlX3RhZyI6InN2ZV9zZCJ9&oh=5f241d3c08d5c819b0c3810d0e21d73b&oe=5B73BF1B
this will load
your browsers default html video player which has a download button
this will all only work if you are logged into FB and have permission to view the video (doesnt' work incognito)
Getting the right URL can take a bit of playing around but it works when you've got it right
Another alternative that worked in Firefox in Feb 2021:
Open the post's permalink
Change the page's URL - replace www with m and load that
Now use Inspector to navigate down to the div containing the video object - and the video URL will be a direct link
Copy-paste that URL into your browser, or create an anchor link to that URL and load your link and right-click to save destination.
It downloads as mp4 including video and audio.
Update, 2 Jul 2021
When I followed my own steps today, pasting the mp4 URL returned a page giving the following error:
Bad URL timestamp
However, I still found a work-around.
Side note: One of the containing divs has ID mobile_injected_video_feed_pagelet.
Facebook now injects the video element when you hit the play button.
That VIDEO element contains the URL you need. The URL does contain "MP4" in the path.
What I did was:
Open Inspector
Hit "Play" on the video
While the video is playing, find the VIDEO element and copy the URL from the VIDEO element
Paste that into a new tab
The new tab would show a smaller thumbnail of the video
Right-click the thumbnail and save the media to your PC
You must hit play for the VIDEO element to appear in the page source.
I'm using Firefox but any browser with an inspector should work.
Add this extension to your chrome browser to download FB videos:
https://chrome.google.com/webstore/detail/video-downloader-plus/njgehaondchbmjmajphnhlojfnbfokng
Once installed, go play the video and click the fb downloader icon (Downward Arrow icon) and choose your desired resolution.
I use Blob Video Downloader extension. It takes a few mins but it opens a new tab with a button to download video. I try it with a 1min video 720p.
For video that is in this blob format
or other formats served by Facebook with the intent to hide the ability to download, you can try loading the page without Javascript. They will serve you a version that is compatible, which means directlink
Tested working 11-2020
I assemble here the necessary steps from the different answers :
Facebook downloads the audio and the video separately, so get the
audio link from the google chrome inspector, by right click on the
video and choosing inspect ,going to Inspector, Network Tab, and
checking the links, use filter:larger-than:50k in the filter area to
select bigger files (change 50k according to the length of your
video), look in the results for mp4 or wav links, remove
&bytestart=number_here &byteend =number_here from the end of the
link, open it and download the audio
Get the video link from the google chrome inspector, using same
steps above, open the link and download the video
Now in order to mix the audio and the video, we need to use ffmeg :
Download ffmpeg build for your OS from its website, use this link
Extract the downloaded zip file
Open your command line tool and cd to :
\Downloads\ffmpeg-2021-04-28-git-1ab74bc193-full_build\ffmpeg-2021-04-28-git-1ab74bc193-full_build\bin
(change according to which version you downloaded)
Assume the input files are in the current folder, the output will be
generated in the current folder too
Mix the audio and the video with ffmpeg using command :
.\ffmpeg.exe -i video.ext -i audio.ext -c:v copy -c:a aac output.mp4

Playing video from youtube link without UIWebView

I want to play a video in my app from youtube link e.g: http://www.youtube.com/watch?v=Uner-3tTY1I.
But i don't want to redirect the user to any web view in the app. Just want to play that video in the video player in the current view of my application.
Is it possible to play the video without redirecting to UIWebView? If possible, how can i do this? Thanks for the help in advance.
The only allowed way seems to be using UIWebview. Doing it other way will violate youtube copyrights.
However there are few open source libraries out there. You can use it at your own risk.
Just use XCDYouTubeVideoPlayerViewController. It uses progressive download + MoviePlayer and AVFoundation frameworks.
To play this video you need to have the link to the video stream that is associated with video you want to play. Unfortunately this isn't so simple to get this link for some movies on YouTube since this link can be encoded for some movies (channel VEVO for example). Read this for more information about encoded links http://www.jwz.org/blog/2013/06/youtube-download-counter-countermeasures-applied/.
Unfortunattely as for now there is no simple way to decode these links. Despite this, you can get the source link for the not encoded films without bigger problems using some calls to the YouTube Api.

How can I have an .mp3 file on my site open in an app that plays MP3's?

I publish MP3s on my site. Since my audience prefers to listen to those MP3s on their iPhones, they tend to 1) download my files, 2) open up iTunes, 3) find the app folder, and 4) drag my MP3 to the audio app of their choice.
It's a tough process.
But they don't want to listen to my MP3s is their iPhone's browser and I can't get all my MP3s into a podcast.
So, I was wondering if there's a URL scheme that would let my readers, click a link on my site and have it automatically open the corresponding MP3 in a program like Apple's Podcast or Downcast or even send it to Dropbox.
This question sounds interesting, the answer is you must known the third app's scheme which contains url parameter, also the the third app must support playing mp3 file online and is already launched in the user's iPhone.
Yep!
There's the "music://" URL schema that opens iPod/Music app. I just don't know if it's valid to content from web, but you can try it out.
Check more information here:
http://wiki.akosma.com/IPhone_URL_Schemes#Music_.2F_iPod

streaming data from a server

I would like to have all my data on a server be streamed into my iphone app.
How does this work?
e.g. images, text and sound
Should this be read into an array and then manipulated?
As I would like the app to be update-able whenever new content is added to the server.
This obviously means building the app in such a way that it wont crash or have errors due to updates.
How is this done? Is there single folder for each which is streamed in e.g. sound clips folder.
Thanks
What i understood from your question is that you want to play sounds, videos on your iphone app over the internet.
Images:
To display image on your iphone over the internet is very easy all you have to do is publish your website somewhere then iphone will use the hyperlink of that image meaning like when you browse any image in your browser you get e.g:
http://www.google.com/images/logos/ps_logo2.png your iphone app will just call this URL to display the image.
For Sound And Videos
They both will also be published on the website and they will have URL so that your iPhone App can access them to pause & stop the sound/video you just have to stop buffering & as a precaution you can save the location of buffer & if you want to Resume just start buffering from the saved buffer location