Without its own streaming media server, and want to use the native video player MPMoviePlayerController in the app to insert video into the interface, the interface can be played directly, or full-screen playback, can be achieved by the following methods
Create a native player first
_movieplayer = [[MPMoviePlayerController alloc] init]; _movieplayer.controlstyle = mpmoviecontrolstyleembedded; _movieplayer.shouldautoplay = NO; _movieplayer.view.frame = CGRectMake (0, 0, hx_screen_width, +); [Self.scrollview Addsubview:_movieplayer.view];
then request Youku and other video pages to load the data
Nsurl *fileurl = [Nsurl urlwithstring:<span style= "Background-color:rgb (240, 240, 240);" >@ "You want to extract streaming address Youku and other pages" </span>]; Nsurlrequest *request = [Nsurlrequest requestwithurl:fileurl]; UIWebView *webview = [[UIWebView alloc]init]; Webview.delegate = self; [WebView Loadrequest:request];
Then by implementing the UIWebView delegate method:
#pragma mark-uiwebviewdelegate-(void) Webviewdidfinishload: (UIWebView *) webview{ nsstring *ljs = @ " Document.documentElement.innerHTML "; NSString *lhtml = [WebView Stringbyevaluatingjavascriptfromstring:ljs]; NSLog (@ "HTML content:%@", lhtml);//above is just printing information for reference, the following is the extract stream //NSString *LJS2 = @ "(document.getElementsByTagName (\" video \ ") [0]). getElementsByTagName (\" source\ ") [0].SRC]; Qiyi NSString *ljs2 = @ "(document.getElementsByTagName (\" video\ ") [0]). src"; Youku,tudou,ku6, Souhu nsstring *lm3u8 = [WebView stringbyevaluatingjavascriptfromstring:ljs2]; NSLog (@ "video source:%@", lm3u8); load to native player play nsurl *movieurl = [Nsurl urlwithstring:lm3u8]; _movieplayer.contenturl = Movieurl; [_movieplayer Preparetoplay];}
Description: WebView to add to your view, otherwise it is never going to load the request;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use Apple native video player MPMoviePlayerController to play videos from Youku and other web pages