Comment lire une vidéo à partir d'une URL dans l'iphone

J'ai une vidéo dans l'url, En un clic sur un bouton j'ai de la lecture d'une vidéo, pour cela, j'ai utilisé UIWebView pour lire cette vidéo, pour cela, j'ai utilisé le code suivant:

-(void)viewDidLoad
{
   NSString *string = @"http://www.boxmusiq.com/ThiruvasakamVideo/VTS_01_2_converted.mp4";
   youtubeview = [[YouTubeView alloc] initWithStringAsURL:string frame:CGRectMake(0, 0, 320, 480)];
   NSLog(@"the url is: %@",string);
   [self.view addSubview:youtubeview];
}

et Dans YouTubeView.m
YouTubeView est une sous-classe de UIWebView;

- (YouTubeView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
{
 if (self = [super init]) 
 {
               //Create webview with requested frame size
   self = [[UIWebView alloc] initWithFrame:frame];

               //HTML to embed YouTube video
   NSString *youTubeVideoHTML = @"<html><head>\
                         <body style=\"margin:0\">\
                         <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
                         width=\"%0.0f\" height=\"%0.0f\"></embed>\
                         </body></html>";

   //Populate HTML with the URL and requested frame size
   NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];

   //Load the html into the webview
   [self loadHTMLString:html baseURL:nil];
       }

 return self;  

}

OriginalL'auteur Shanmugaraja G | 2011-03-23