Youtube video autoplay on iPhone's Safari or UIWebView

前端 未结 5 1703
遇见更好的自我
遇见更好的自我 2020-12-02 19:35

Is it possible to get a youtube video to autoplay on Safari and/or UIWebView? I\'ve seen this done in an iPhone app, the tableview displays cells that do not have Youtube pr

5条回答
  •  没有蜡笔的小新
    2020-12-02 19:45

    The "button click" method mentioned above worked for me in iOS6, but only the first time. Upon repeat loads, it would not start the video. All things equal, I figured it must be a caching issue, or a cookie. Turns out clearing the cookies for youtube made it work for me.

    for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
          NSLog([cookie domain]);
          if([[cookie domain] isEqualToString:@".youtube.com"]) {
    
              [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
          }
    }
    

    Hope this can help someone else trying to figure this out for iOS6!

提交回复
热议问题