i wish autoplay youtube video specific time using objective-c. used following:
- (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; nslog(@"%s",__function__); appdelegate = (appdelegate *) [[uiapplication sharedapplication]delegate]; float width = 309.0f; float height = 196.0f; nsstring *youtubeurl = @"http://www.youtube.com/embed/gyf1kjauzco?autoplay=1"; uiwebview *wv = [[uiwebview alloc] init]; wv.frame = cgrectmake(0, 0, width, height); nsmutablestring *html = [[nsmutablestring alloc] initwithcapacity:1]; [html appendstring:@"<html><head>"]; [html appendstring:@"<style type=\"text/css\">"]; [html appendstring:@"body {"]; [html appendstring:@"background-color: transparent;"]; [html appendstring:@"color: white;"]; [html appendstring:@"}"]; [html appendstring:@"</style>"]; [html appendstring:@"</head><body style=\"margin:0\">"]; [html appendformat:@"<iframe class=\"youtube-player\" type=\"text/html\" width=\"%f\" height=\"%f\" src=\"http://www.youtube.com/embed/gyf1kjauzco?autoplay=1\" allowfullscreen frameborder=\"0\"></iframe>", width, height]; [html appendstring:@"</body></html>"]; [wv loadhtmlstring:html baseurl:nil]; [self.videoview addsubview:wv]; }
but video doesn't autoplay. getting wrong? how solve this?
i had similar problem auto playing youtube video,
can find solution here here
dont forget set uiwebview
mediaplaybackrequiresuseraction
property no.
Comments
Post a Comment