how to play video in ruby on rails

1,203 views
Skip to first unread message

honey ruby

unread,
Dec 28, 2011, 5:55:48 AM12/28/11
to Ruby on Rails: Talk
hey everyone i want to add a video and play it using ruby on rails .
how can i do it. can anyone help me plzz..

Thanks in advance

Ralph Shnelvar

unread,
Dec 28, 2011, 10:31:39 AM12/28/11
to honey ruby
hr> hey everyone i want to add a video and play it using ruby on rails .
hr> how can i do it. can anyone help me plzz..

hr> Thanks in advance

After struggling with this for several days, I have finally been able to get some videos to play in Rails 3.1.2. There may be other ways of playing videos and if there are I'd sure like to hear about
it.

Here is some preliminary documentation. I'm gonna write up more when I get all the kinks out.


The following instructions are for Rails 3.1.2

1) Download from here: http://rubydoc.info/gems/jw_player_helper/0.0.1/file/README.markdown#


2) Add
gem 'jw_player_helper'
to your Gemfile


3) Do
bundle install
or
bundle install --deployment
depending on your needs.


4) Assuming that you are using sprockets (which seems to be the recommended default), make sure that swfobject.js is accessible from your assets.

You can check if swfobject.js is accessible by displaying Rails.application.config.assets.paths.

Rails.application.config.assets.paths is an array of fully qualified directory names where assets can be found. Make sure that swfobject.js is in one of the directories and not in a subdirectory
of one of these directories.


5) Place your video(s) in a directory underneath public. I chose a directory named "videos".

= video_player( {:file => 'videos/my_video.flv'}, {:width => '100%'} )

Let me know if you get videos to work and if this sketch of documentation needs to be beefed up.

Oh, this sketch is due to a frustrating 5 days of trying to get videos to play on 3.1.2. I hope it takes you a lot less time.

Santosh Kumar Mohanty

unread,
Dec 29, 2011, 2:30:08 AM12/29/11
to rubyonra...@googlegroups.com
Hey,

  According to my knowledge you can play the video url using a iframe or using Y_tube gem...




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


hanish jadala

unread,
Dec 29, 2011, 3:01:26 AM12/29/11
to rubyonra...@googlegroups.com
i am using 2.3.8 rails and ruby 1.8.7 does it work in this version. is it mandatory to have rails 3

On Wed, Dec 28, 2011 at 9:01 PM, Ralph Shnelvar <ral...@dos32.com> wrote:

Ben Eggett

unread,
Dec 29, 2011, 3:16:49 AM12/29/11
to Ruby on Rails: Talk
Sorry to be harsh, but if you don't know how to code to play videos,
you probably ought to forget about RoR for a bit and start with
learning front-end coding and playback mechanisms. Once you have some
solid tools built up, you can then bring it back into RoR and use Ruby
to draw your video players and source files dynamically.

There are plenty of good places to start, depending on your needs:
http://camendesign.com/code/video_for_everybody
http://sandbox.thewikies.com/vfe-generator/
http://flowplayer.org
http://videojs.com

or simply youtube.com - embedding videos.

You need to know the difference between front-end and back-end tools
(client side and server side). Realizing that RoR will ultimately
deliver front-end code to the user in some form or another

Hackeron

unread,
Dec 30, 2011, 9:00:37 AM12/30/11
to Ruby on Rails: Talk
Some times it's nice to know if there is a defacto standard - the
current HTML5 generation of players are still pretty buggy.

The best I've used is mediaelementjs, there is a rails gem here:
https://github.com/tobsch/mediaelement_rails

On Dec 29, 8:16 am, Ben Eggett <benegg...@gmail.com> wrote:
> Sorry to be harsh, but if you don't know how to code to play videos,
> you probably ought to forget about RoR for a bit and start with
> learning front-end coding and playback mechanisms. Once you have some
> solid tools built up, you can then bring it back into RoR and use Ruby
> to draw your video players and source files dynamically.
>
> There are plenty of good places to start, depending on your needs:
>  http://camendesign.com/code/video_for_everybodyhttp://sandbox.thewikies.com/vfe-generator/http://flowplayer.orghttp://videojs.com

Felipe Fontoura

unread,
Dec 28, 2011, 8:29:21 AM12/28/11
to rubyonra...@googlegroups.com
Hello!

You can play easy with flash players. So isn't a ruby task, you can add in view layer as html/js code.

[]'s

---
Felipe Fontoura
Eng. de Computação
http://www.felipefontoura.com


2011/12/28 honey ruby <emailtoh...@gmail.com>
hey everyone i want to add a video and play it using ruby on rails .
how can i do it. can anyone help me plzz..

Thanks in advance

hanish jadala

unread,
Dec 31, 2011, 3:23:00 AM12/31/11
to rubyonra...@googlegroups.com
This playing a video is a new one for me so i am learning it. if u don't know how play a video it does not mean you don't know ROR . New things has to learned only by researching and in that process only i posted it. 

Rishi J.

unread,
Mar 2, 2013, 6:42:34 AM3/2/13
to rubyonra...@googlegroups.com
Hi Ralph Shnelvar

I followed your steps for using jw_player_helper. I got the jw player on
my view but somehow it does not play any video. I have put up the video
under public/videos .When click on play, it shows no-access or file not
found at videos/3.mp4 . What I could be missing?
I am working on Rails 3.2.11

--
Posted via http://www.ruby-forum.com/.

nannasin smith

unread,
Mar 6, 2013, 4:16:07 AM3/6/13
to rubyonra...@googlegroups.com
Make sure that swfobject.js is in one of the directories and not in a
subdirectory of one of these directories.
http://www.hqew.net
Reply all
Reply to author
Forward
0 new messages