Play a vimeo video on iphone

此生再无相见时 提交于 2019-12-08 05:02:44

问题


I am using following htmlString to run a file on vimeo on iPhone.

<iframe src=\"http://player.vimeo.com/video/8118831?api=1title=0&amp;byline=0&amp;portrait=0&amp;color=008efe&amp\";autoplay=1&amp;loop=1 width=\"320\" height=\"480\" frameborder=\"0\">"//@"</iframe>"

It is playing fine but I want the video to play without user interaction. And I am failing to do so.

I try to add autoplay=1 as mentioned in http://developer.vimeo.com/player/embedding it does not autoplay. This post - http://vimeo.com/forums/topic:45193 makes me believe autoplay does not work on IPhone. Thus I tried to use JavaScript to play a video file. But vimeo does not expose the video file. So I try to use vimeo own Java API but it has no functions to play the video file (http://developer.vimeo.com/player/js-api) .

My Question is , Is there a way to play a vimeo file on iPhone with out user interaction and how it can be done.


回答1:


Seems like vimeo has updated its api and now there is a function to play the video . I used following html String :

NSString *htmlString = [NSString stringWithFormat:
                                                @"<html><head>"
                                                "<script src=\"froogaloop.js\"></script>"
                                                " <script>"
                                                    "function ready()"
                                                        "{$f(document.getElementById(\"player\")).api(\"play\");}"
                                                    "function func1() "
                                                        "{$f(document.getElementById(\"player\")).addEvent(\"ready\", ready);}"
                                                    "window.onload=func1;"
                                                "</script></head><body>"
                                                       "<iframe id=\"player\" src=\"http://player.vimeo.com/video/39287488?api=1&amp;player_id=player\" width=\"315\" height=\"455\" frameborder=\"0\" webkit-playsinline>"
                                               " </iframe></body></html>"];

and onViewDidFinishLoad

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"webview loaded");
    NSString *path = [[NSBundle mainBundle] pathForResource:@"froogaloop" ofType:@"js"];
    NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    [webView stringByEvaluatingJavaScriptFromString:jsCode];
}



回答2:


I also tried alot for doing that but i couldn't. I think it is not allowed by iphone.

( Like u can not play video in browser (It automatically opens native video player) )



来源:https://stackoverflow.com/questions/11990378/play-a-vimeo-video-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!