Download youtube video in iOS Swift - ios

I am looking for solution to download video from youtube.
i saw in youtube native application in ios they are providing a feature to save video for offline.
Is there any solution to download video in application? Or any API to download video.

You can download video file from Youtube if we know youtube URL of the video. First you need to download files (HCYoutubeParser) into your project. Now you need to call following function into your code:
let video = HCYoutubeParser.h264videosWithYoutubeURL(yturl!)
let downloadURL = video["medium"] as! String
Where yturl is video URL. We need to pass it into h264videosWithYoutubeURL function. HCYoutubeParser is a class which provides methods for converting Youtube video watch URL into video download URL. This can be done by Youtube video id also. Following method is used for that:
let video = HCYoutubeParser.h264videosWithYoutubeID(ytID!)
let downloadURL = video["medium"] as! String
Where ytID is id of Youtube video. In these code snippet we are getting download URL of medium quality video. For more info and HCYoutubeParser class follow this link: http://findnerd.com/list/view/How-to-download-videos-from-YouTube-in-iOS/22437/

If you are looking for a library then XCDYouTubeKit would be a good choice. If you are looking for an open source app then YouTag might be helpful.

Related

Play 360 live video stream

I'm using MobileVLCKit for playing the live streamings for a while now, but now I've been tasked to play 360 live video streams I've tried to stream the video normally but it shows rectangular view for overall video what I want is play like 360 videos so the user can interact with the video. The current playback for video is like
Code for playback from MobileVLCKit is below
let url = URL(string: "rtmp://\(streamurl)/LiveApp/022036535502121746572694")
player.media = VLCMedia(url: url!)
player.drawable = self.videoView
player.play()
If anybody has streamed 360 videos please let me know How can I do that?
TIA Any links or suggestions will also be much appreciated.
The latest version of VLC player does support 360 video playback but ti may be that the MobileVLCKit is a subset that does not include this yet - certainly it is not obvious in the documentation that it does.
There is a way you can use the full VLC player from your app, if that works for you as a workaround, by using an 'x-callback-url'.
The iOS VLC documentation contains some instructions for this at the time of writing (https://wiki.videolan.org/Documentation:IOS/) including the specific format below:
vlc-x-callback://x-callback-url/ACTION?url=...&PARAMETER=...
Actions:
stream: VLC plays the stream provided by the URL parameter
download: VLC will download the file provided by the URL parameter
Optional Parameters:
filename: VLC will store the file under the given filename when using the download action.
x-success: VLC will open another x-callback-url once playback is done.
x-error: VLC will open another x-callback-url if playback fails. Requires version >2.5.0 or later
Its also worth noting that the player has to know the video is 360 - the video may indicate this somehow, in its header info typically, or you may find you need to tell the player itself to play the video as 360. It may be worth playing with some online or downloadable demo VR players to get a feel - e.g.:
https://bitmovin.com/demos/vr-360
https://www.jwplayer.com/developers/web-player-demos/360-video/
http://demo.theoplayer.com/vr-and-360

using livestream video in iOS application

I want to use video from some live streaming channel i.e. twitch, youtube in my iOS application without using their plugins. How can i do so?
I'm trying to get url of the video so that i can play it via moviePlayer or something else in my application. At the moment, i'm using OBS for uploading the live-stream on twitch.tv
I've found the following link, but again i'm unable to find the url of the video so can't use the solution mentioned How can I use Livestream player in iOS/Android app?
Thanks,
I have solved the issue using webView. For Youtube we've stream id and we put it in url as "https://www.youtube.com/watch?v=videoId".
For ustream i made url as "https://www.ustream.tv/embed/channelId".
If you don't want to use webView then you can use helper libraries for these platforms i.e. YTPlayer, twitch etc.

Youtube ios player helper can't play video

I am using this library https://github.com/youtube/youtube-ios-player-helper
in my project. The player works well if I use the video Id given by the sample (M7lc1UVf-VE). If I use the video Id from r random video on youtube it shows:
An error occurred, please try again later. Learn More
Do I need to enable a youtube data API or something like that???
cause I see another IOS Youtube helper needs to do so.
https://github.com/youtube/yt-direct-lite-iOS
Thanks.
add this in your playerVars #"origin" :#"http://www.youtube.com" it will work.
If you only want to play youtube video, no API access is needed.
I work on with this library without any error, did you replace "M7lc1UVf-VE" with the correct video id?

Can I get youtube video as mp3 sound in iOS ?

as mentioned in the question
Can I get the youtube as sound file with any extension
I mean specifically with using JSON or any other way ?
One way to get songs from Youtube is to use their API, and search for your song. It will return a youtubeID url of video/song.
You can then stream this into an iOS app.
A handy framework to extract video url from youtube ID url, is LBYoutubePlayer which can be found here https://github.com/larcus94/LBYouTubeView
You would then need to extract the audio from the video.
Technically, that could all work. Not sure if it goes beyond Youtube's terms and services though.

How to play video in streaming by using iOS GoogleDrive SDK?

I want to play video in streaming by using iOS GoogleDrive SDK.
GoogleDrive App in iOS app store can play video in streaming by YouTube.
I have seen this post:
http://apiblog.youtube.com/2009/02/youtube-apis-iphone-cool-mobile-apps.html
According to the post, the key of play video is the YouTube source link.
The link lists GoogleDrive's all of file properties:
https://developers.google.com/drive/v2/reference/files
All file's properties were tried to instead of the YouTube source link, but that doesn't work.
Could anyone tell me how to get the correct link to play video by YouTube?
Thank you very much.
You can the URL in the embedLink field to get a streaming player for the video.

Resources