在iphone上播放vimeo视频 [英] Play a vimeo video on iphone

查看:126
本文介绍了在iphone上播放vimeo视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下 htmlString 在iPhone上的vimeo上运行文件。

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.

我尝试添加 autoplay = 1 ,如 http://developer.vimeo.com/player中所述/嵌入它不会自动播放。这篇文章 - http://vimeo.com/forums/topic :45193 让我相信 autoplay 在iPhone上不起作用。因此我尝试使用 JavaScript 来玩一个视频文件。但vimeo没有暴露视频文件。所以我尝试使用vimeo自己的Java API,但它没有任何功能可以播放他的视频文件(http://developer.vimeo.com/player/js-api)。

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) .

我的问题是,有没有办法在iPhone上播放vimeo文件,无需用户交互以及如何完成。

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

推荐答案

似乎vimeo更新了它的api,现在有一个播放视频的功能。我使用了以下html字符串:

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>"];

和onViewDidFinishLoad

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];
}

这篇关于在iphone上播放vimeo视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆