问题
I am using following htmlString
to run a file on vimeo on iPhone.
<iframe src=\"http://player.vimeo.com/video/8118831?api=1title=0&byline=0&portrait=0&color=008efe&\";autoplay=1&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&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