Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

ruby - Error loading media: File could not be played error in jw_player rails

I am using the below mentioned code to play a video from my local disk. But its not working instead of that it's throwing Error loading media: File could not be played error error. I have mentioned the code below.

 <%= jwplayer_assets %>
 <%= jwplayer ({:file => "/home/user/Downloads/digital.mp4", :image => "/home/user/Downloads/Retreats_21.jpg"}) %>

I'am new to this jw_player. so please help me to solve this issue. Thanks in advance..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Download jwplayer from http://www.longtailvideo.com/jw-player/download/

Put these files to the particular directory:-

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

Then add these line in application.js

//= require jwplayer
//= require jwplayer.html5

On the page where you are playing video, add these lines

<script type="text/javascript">jwplayer.key="YOUR_JWPLAYER_KEY";</script>
<div id="video">Loading the player ...</div>
<script type="text/javascript">
jwplayer("video").setup({
    flashplayer: "<%=asset_path('jwplayer.flash.swf')%>",
    file: "<%= file_path %>",
    height: 360,
    width: 640,
    analytics: {
        enabled: false,
       cookies: false
   }
});
</script>

https://account.longtailvideo.com/#/account from where you can get your Self-Hosted Player License Key (YOUR_JWPLAYER_KEY) in signing up from Get Your License Key portion.

Take a look https://github.com/shamsulsham89/jwplayer-rails3.2

Please test it first on Chrome Version 30


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...