Can anyone give me an idea how can we show or embed a YouTube video if we just have the URL or the Embed code?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Is there a way to play audio on a mobile browser w
If you want to upload videos programatically, check the YouTube Data API for PHP
You have to ask users to store the 11 character code from the youtube video.
For e.g. http://www.youtube.com/watch?v=Ahg6qcgoay4
The eleven character code is : Ahg6qcgoay4
You then take this code and place it in your database. Then wherever you want to place the youtube video in your page, load the character from the database and put the following code:-
e.g. for Ahg6qcgoay4 it will be :
From both long and short youtube urls you can get the embed this way:
Hope it helps someone
You can simply create a php input form for
Varchar date
,give it avarchar
length of lets say 300. Then ask the users to copy and paste the Embed code.When you view the records, you will view the streamed video.Just a small update to Alec Smart's answer: since AS2 is deprecated now, the '?version=3' is required to get his example to work. See the Youtube reference at YouTube Embedded Players and Player Parameters under "Selecting content to play" for details.
In other words:
Apparently, the Youtube reference above does this as follows (the inner embed presumably used as a fallback for browsers that don't yet support the object tag):
Or using iframes (replace http://example.com with your site's domain):
Here is some code I've wrote to automatically turn URL's into links and automatically embed any video urls from youtube. I made it for a chat room I'm working on and it works pretty well. I'm sure it will work just fine for any other purpose as well like a blog for instance.
All you have to do is call the function "autolink()" and pass it the string to be parsed.
For example include the function below and then echo this code.
`