Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. - (void)loadwebViewToPlay {
  2.  
  3. NSString * videoHtml = @"<html><head><style>body{margin:0px 0px 0px 0px;}</style></head> <body> <div id="player"></div> <script> var tag = document.createElement('script'); tag.src = 'http://www.youtube.com/player_api'; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; function onYouTubePlayerAPIReady() { player = new YT.Player('player', { width:'200', height:'200', videoId:'bHQqvYy5KYo', events: { 'onReady': onPlayerReady } }); } function onPlayerReady(event) { event.target.playVideo(); } </script> </body> </html>";
  4.  
  5. UIWebView * webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
  6. webview.backgroundColor = [UIColor clearColor];
  7. webview.opaque = NO;
  8. //videoView.delegate = self;
  9. [self.view addSubview:webview];
  10. webview.mediaPlaybackRequiresUserAction = NO;
  11.  
  12. [webview loadHTMLString:videoHtml baseURL:[[NSBundle mainBundle] resourceURL]];
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement