2012-12-20 83 views
0

我想從我的web視頻加載視頻,這個視頻不是來自youtube我沒有得到如何加載它可以任何人幫助我以外的代碼如何在webView以外的視頻加載視頻

- (void)embedYouTube:(NSString*)url frame:(CGRect)frame 
{ 
    NSString* embedHTML = @"<html><head> <style type=\"text/css\">body {background-color: transparent;color: white;}</style></head><body style=\"margin:0\"><embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" width=\"%0.0f\" height=\"%0.0f\"></embed></body></html>"; 
    NSString* html = [NSString stringWithFormat:embedHTML, url, frame.size.width, frame.size.height]; 

    // UIWebView *webView =[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
    [vebview loadHTMLString:html baseURL:nil]; 
    [self.view addSubview:vebview]; 
} 
- (void)viewDidLoad 
{ 
    [self embedYouTube:@"http://player.vimeo.com/video/32983838" frame:CGRectMake(0, 0, 320, 449)]; 
    [super viewDidLoad]; 
} 

回答

0

您可以使用MPMoviePlayerController控件播放視頻。

<MediaPlayer/MediaPlayer.h>框架導入應用程序。

.h文件中

#import <MediaPlayer/MediaPlayer.h> 

MPMoviePlayerController *moviePlayerController; 

.m文件

-(void)startVideo:(NSString*)fileURL 
{ 
    UIWebView *w = [[UIWebView alloc] init]; 
    w.frame = CGRectMake(10, 0, 300, 340); 
    w.backgroundColor = [UIColor clearColor]; 

    moviePlayerController = nil; 
    CGRect rect = CGRectMake(10, 0, 300, 400); 

    moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL]; 
    [moviePlayerController.view setFrame:rect]; 
    moviePlayerController.fullscreen = YES; 


    [moviePlayerController play]; 

    [w addSubview:moviePlayerController.view]; 
} 

在這裏,我用裏面查看動態網頁視圖。您可以通過XIB直接使用它。

希望它對你有幫助。

謝謝。

+0

我可以不導入媒體文件或任何其他方式嗎? – NullData

+0

我想要這個鏈接http://player.vimeo.com/video/32983838 – NullData