试图在iOS上实现JW Player

Lud*_*uda 9 iphone objective-c jwplayer ios

我是JW的新手,似乎无法实现最简单的球员.请帮帮我.

我创建了一个html并将其放入我的项目中.与jwplayer.flash.swf,jwplayer.html5.js,jwplayer.js在同一个地方

我的html文件看起来像这样(Home.html):

<html>
<head>
  <title>Title of the document</title>
  <script type="text/javascript" src="jwplayer.js"></script>
  <script type="text/javascript">jwplayer.key="myKey"</script>
</head>
<body>
  <div id='player_8955'></div>
  <script type='text/javascript'>
    jwplayer('player_8955').setup({
      file: "http://www.youtube.com/watch?v=ac7KhViaVqc",
      width: "480",
      height: "270",
      image: "http://content.bitsontherun.com/thumbs/3XnJSIm4-640.jpg",
    });
  </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在控制器类中:

- (void)viewDidLoad
{
    [super viewDidLoad];
    htmlPlayerWebView=[[UIWebView alloc]initWithFrame:CGRectMake(20, 51, 674,381)];
    [self.view addSubview:htmlPlayerWebView];
}
-(void)loadVideo
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Home" ofType:@"html"];
    NSString *HTMLString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    [htmlPlayerWebView loadHTMLString:HTMLString baseURL:[NSURL URLWithString:path]];
}
Run Code Online (Sandbox Code Playgroud)

这些函数被调用.但没有任何反应.

Lud*_*uda 1

我发现问题: UIWebView 无法访问项目文件。所以 jwplayer.js 没有加载。因此,要么将播放器加载到某个网络服务器,要么替换

<script type="text/javascript" src="jwplayer.js"></script>
Run Code Online (Sandbox Code Playgroud)

<script type="text/javascript"> 
Run Code Online (Sandbox Code Playgroud)

文件 jwplayer.js 的内容(右键单击 jwplayer.js -> 查看源代码 -> 复制 -> 粘贴到此处)

</script>
Run Code Online (Sandbox Code Playgroud)