Forum: Ruby on Rails youtube and rails, how to show video in player

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jon (Guest)
on 2007-01-03 23:29
Hi,

I have used the YouTube api to extracta set amount of video's, is anyone
aware of how I can show these in a player on my ruby on rails site?

are there any plugins that may help?

cheers
jon
Chris T (Guest)
on 2007-01-04 01:31
(Received via mailing list)
koloa (Guest)
on 2007-01-04 17:41
awesome post...but is there a way to just embed a particular youtube
video with an id? i see only options for feature, user, get by tag, and
friends of user.
jon (Guest)
on 2007-01-04 18:49
koloa wrote:
> awesome post...but is there a way to just embed a particular youtube
> video with an id? i see only options for feature, user, get by tag, and
> friends of user.

yeah, I discovered it can be done easily by using this code below

<object width="371" height="306"><param name="movie"
value="http://www.youtube.com/v/<%=params[:video_id]%>&au...
/><embed
src="http://www.youtube.com/v/<%=params[:video_id]%>&au...
type="application/x-shockwave-flash" width="371"
height="306"></embed></object>
koloa (Guest)
on 2007-01-04 18:56
thanks job for sharing!


jon wrote:
> koloa wrote:
>> awesome post...but is there a way to just embed a particular youtube
>> video with an id? i see only options for feature, user, get by tag, and
>> friends of user.
>
> yeah, I discovered it can be done easily by using this code below
>
> <object width="371" height="306"><param name="movie"
> value="http://www.youtube.com/v/<%=params[:video_id]%>&au...
> /><embed
> src="http://www.youtube.com/v/<%=params[:video_id]%>&au...
> type="application/x-shockwave-flash" width="371"
> height="306"></embed></object>
Chris T (Guest)
on 2007-01-06 20:30
(Received via mailing list)
koloa wrote:
>
> awesome post...but is there a way to just embed a particular youtube
> video with an id? i see only options for feature, user, get by tag,
> and friends of user.
>
Sure. You can either use video_details(video_id)  to find all the
details for the video (and also make it dead simple to display, or just
use the code from
#embed_html -- all it does is wrap the id in html, like this:

<object width="#{width}" height="#{height}">
  <param name="movie" value="#{embed_url}"></param>
  <param name="wmode" value="transparent"></param>
  <embed src="#{embed_url}" type="application/x-shockwave-flash"
   wmode="transparent" width="#{width}" height="#{height}"></embed>
</object>

where width and height are passed to the embed_html method

and where embed_url is generated from the video's page on YouTube by

@embed_url = @url.delete('?').sub('=', '/')

So, you don't actually need to even use the gem if you know the id, and
could generate the embedded video yourself using something like
"http://www.youtube.com/v/#{youtube_id}"

HTH
This topic is locked and can not be replied to.