JW-Player和Rails 3.2 [英] JW-Player and Rails 3.2

查看:95
本文介绍了JW-Player和Rails 3.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中使用JW-Player.对此问题进行一些研究,似乎已经放弃了生产宝石的一些努力,而最新的文献却没有记载.所以,这就是我要怎么做:

I'm trying to use JW-Player in my application. Researching the issue a bit, there seems to be several abandoned efforts to produce a gem, and the latest is undocumented. So, here's how I'm going about it:

我下载了JW-Player版本6,解压缩并将文件复制到/app/assets/javascripts目录中,如下所示:

I downloaded the JW-Player version 6, unzipped and copied the files in my /app/assets/javascripts directory as follows:

app/assets/javascripts/jwplayer/jwplayer.js
app/assets/javascripts/jwplayer.html5.js
app/assets/javascripts/jwplayer.flash.swf

在我的app/views/layouts/application.html.erb中,我具有以下内容:

In my app/views/layouts/application.html.erb, I have the following:

<head>
    <%= javascript_include_tag "/assets/javascripts/jwplayer/" %>
</head>

在app/views/pages/about.html.erb中,我具有以下内容:

and in app/views/pages/about.html.erb, I have the following:

<%= jw_player("http://xxxxx/video.mp4",
            :width => 200, :height => 110) %>

当我单击关于"页面链接时,会发生以下情况:

Here's what happens when I click on the About page link:

Showing xxxxxxxx/app/views/pages/about.html.erb where line #10 raised:

undefined method `jw_player' for #<#<Class:0x007fe77e37c018>:0x007fe780c1f678>

JW-Player的首次使用.

First time user of JW-Player.

推荐答案

在实现JWPlayer 6.6时,我们始终选择将jwplayer.flash.swf文件放入公用文件夹中,以使Flash模式起作用,但是像这样分开文件似乎非常混乱.我最终使它在开发和生产上都能起作用的是:

When implementing JWPlayer 6.6, we stood before the choice of putting the jwplayer.flash.swf file into the public folder, to make the flash mode work, but it seemed very messy to have the files separated like that. What I did in the end to make it work both on development and production was:

  • 将所有3个文件放入供应商/资产/javascripts/jwplayer
  • 将jwplayer.js重命名为jwplayer.js.erb
  • 在jwplayer.js.erb中,像这样更新Flash文件路径配置(带有html5文件路径配置的第一行仅供参考)

  • Put all 3 files to vendor/assets/javascripts/jwplayer
  • Rename jwplayer.js to jwplayer.js.erb
  • Inside jwplayer.js.erb, update the flash file path config like this (the 1st line with the html5 file path config is just for reference)

j={type:"html5",src:e.base+"jwplayer.html5.js"},
b={type:"flash",src:"<%= asset_path('jwplayer/jwplayer.flash.swf') %>"};

(请注意,删除Flash文件路径的路径之前的"e.base +"-这是允许在开发环境中使用相对路径的技巧)

(note that the "e.base+" before the path was removed for the flash file path - that's the trick that allowed working relative paths in the development environemtn)

据我了解,JWPlayer许可证允许进行如下修改: 适应 为了行使本服务条款下的权利,应允许发布者进行合理必要的修改,例如,将产品整合到发布者的网站或其他财产中的修改. Publisher所创建的所有改编均严格供其自己使用,并且禁止Publisher分发其创建的任何改编.公司保留自行决定禁止使用任何改编作品的权利."

In my understanding, the JWPlayer license allows modifications like this: "Adaptations Publisher shall be permitted to make Adaptations reasonably necessary for the purpose of exercising its rights under these Terms of Service, such as Adaptations to integrate the Products into Publisher’s websites or other properties. All Adaptations created by Publisher are strictly for its own Use and Publisher is prohibited from Distributing any Adaptation it creates. The Company reserves the right to prohibit the Use of any Adaptation in its sole discretion."

这篇关于JW-Player和Rails 3.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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