Monday, 19 May 2014

Playing embedded video in iOS

NSString* embeddtext =@"<iframe width=\"560\" height=\"315\" src=\"//www.youtube.com/embed/Neff9scaCCI\" frameborder=\"0\" allowfullscreen></iframe>";

NSLog(@"Full code = %@",embeddtext);

embeddtext = [embeddtext substringFromIndex:[embeddtext rangeOfString:@"src=\""].location+[embeddtext rangeOfString:@"src=\""].length];
embeddtext = [embeddtext substringToIndex:[embeddtext rangeOfString:@"\""].location ];

if([embeddtext rangeOfString:@"http"].location==NSNotFound)
    embeddtext=[NSString stringWithFormat:@"http:%@",embeddtext];

NSLog(@"video src = %@",embeddtext);

NSString *html = [NSString stringWithFormat:@"<iframe width=\"300\" height=\"250\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>",embeddtext];

[webView loadHTMLString:html baseURL:[NSURL URLWithString:nil]];

1 comment:

  1. https://github.com/youtube/youtube-ios-player-helper

    ReplyDelete