开发者

Adding video link and playing the video in my webpage

I am currently working on a website where user is able to update his/her status on a tex开发者_如何学Got area. If the user enters a link(For example, it is the video link), i should have a script that detects the link and embed it as a video once the user submits the status. It is similar like Facebook status update. Can anyone advice me, how can i go about doing it? I do not want to use paid services which are available on the net as the website i am doing is for students and i am doing the project for free.

The current framework i am using for my development is cakephp (PHP).


A jQuery plugin to hook into the YouTube Chromeless Video API.

Sample Usage:

<a href="http://www.youtube.com/watch?v=sxUjB3Q04rQ&quot; class="video-link">Bolt Arms - Around the World</a>

$(document).ready(function() {
  $('a.video-link').ytchromeless();
});

Requirements:

  • jQuery: http://jquery.com/
  • SWFObject: http://code.google.com/p/swfobject/
  • YouTube Chromeless Video Plugin: http://github.com/davist11/YouTube-Chromeless

Options:

  • videoWidth : '640'
  • videoHeight : '360'
  • videoIdBase : 'ytplayer'
  • params : { allowScriptAccess: 'always', wmode: 'transparent' }


oEmbed is a great solution for this problem. It will return a formatted JSON array from a URL (of a video), including the embed code along with some useful metadata. I would recommend using oEmbed and switching on the hostname of the URL you are provided. For example, if it's youtube, send the request to youtube's oEmbed. If it's Vimeo, send it off to Vimeo, etc...

I would read up more on oEmbed here: http://oembed.com/

Here is YouTube's documentation on how to implement oEmbed: http://apiblog.youtube.com/2009/10/oembed-support.html

I've implemented oEmbed in the beforeSave() in cakePHP before and it worked wonderfully.


First, just detect if a link is given. You can use regex for that. Then if it appears to be a link, just do something like this:

if ($isLink) {
   echo "<embed .... src='$link'></embed>"
}

Easy enough :)

EDIT

See this link if you want to embed in html 4

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜