YouTube video playback broken on iOS6 (works fine on iOS5)

前端 未结 8 2195
南旧
南旧 2020-12-13 16:13

In my app, I have a button which, when pressed, lets you watch a youtube video (a movie trailer). Within the app, without launching safari. Below you can see a code snippet.

8条回答
  •  一向
    一向 (楼主)
    2020-12-13 16:47

    I believe the problem is that when webViewDidFinishLoad was triggered, the UIButton was not added to the view yet. I implemented a small delay to find the button after the callback is returned and it works for me on ios5 and ios6. drawback is that there is no guarantee the UIButton is ready to be found after the delay.

    - (void)autoplay {
        UIButton *b = [self findButtonInView:webView];
        [b sendActionsForControlEvents:UIControlEventTouchUpInside]; }
    
    - (void)webViewDidFinishLoad:(UIWebView *)_webView {
        [self performSelector:@selector(autoplay) withObject:nil afterDelay:0.3]; }
    

    I had to use the url http://www.youtube.com/watch?v=videoid this is the only way it will work for me

提交回复
热议问题