Playing Youtube video in the app is easy and well documented around.
There are two problems with that:
Does anyone have code to:
To download the video from YouTube:
NSTemporaryDirectory()
or a temp-named file in your Documents directory).sendSynchronousRequest:returningResponse:error:
, of course.connection:didReceiveResponse:
delegate method, read out the length of data to be downloaded for proper updating of the progress bar.connection:didReceiveData:
delegate method, write the data to the output stream/file handle and update the progress bar as necessary.connectionDidFinishLoading:
or connection:didFailWithError:
, close the output stream/file handle and rename or delete the temporary file as appropriate.To play it back, just use NSURL's fileURLWithPath:
to create a URL pointing to the local file in the Documents directory and play it as you would any remote video.