How to Get Youtube IDS from url's list PHP - youtube

Sorry may be very beginner question. i have a text area with post method where i'll list youtube URLS like this:
http://www.youtube.com/watch?v=bT7kCbgEAqw
http://www.youtube.com/watch?v=AwyucYgVKb0
http://www.youtube.com/watch?v=QP8PyUhx1AU
http://www.youtube.com/watch?v=AvTg20fYZcE
i want just video ids, what is good way to get video ids like this:
bT7kCbgEAqw
QP8PyUhx1AU
AwyucYgVKb0
AvTg20fYZcE
Thanks :)

$vid_id = explode("?v=", $link);
$vid_id = $video_id[1];
Make $link your URL and then this will return everything after the ?v= in the URL.

Because youtube urls can also be http://www.youtube.com/v/id de explode wil not always work.
Following code will get the v id with both urls.
<?php $youtube_url = 'http://www.youtube.com/watch?v=XXXXXXXX';
parse_str(parse_url($youtube_url, PHP_URL_QUERY), $youtube); ?>
<object width="400" height="224">
<param name="movie" value="https://www.youtube-nocookie.com/v/<?= $youtube['v'] ?>"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="https://www.youtube-nocookie.com/v/<?= $youtube['v'] ?>" type="application/x-shockwave-flash" width="400" height="224" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

Related

How to return a local PDF document in a View in MVC

I am trying to show a locally stored PDF document on my MVC Web application.
What I have tried so far is not quite useful. I tried with the object tag in html but it just says : Access denied.
<object type="application/pdf" data="LocalPathToMyFile" width="958" height="726" id="fbContainer" style="visibility: visible;">
<param name="wmode" value="transparent">
<param name="allowScriptAccess" value="always">
<param name="bgcolor" value="#ffffff">
</object>
We put them in an iframe like this.
<iframe id="external" src"yourSource" width="100%" style="background:#FFF; height:100%; margin:0; padding:0; overflow:scroll"></iframe>
if that gives you a similar error probably permisions.

Whats the best way to embed a flash file from a link?

I have looked around, but still have not found a very good answer to my question.
I would like to know how I can embed a flash game into my website Via HTML or Java in order for it to play.
I have the SWF file, but am unable to put the file on the site, so I got this link "https://dl-web.dropbox.com/get/flight.swf?w=AAAYS8vwABuIJB3QbyhV1kSX778W0mXh4xRoQ0ADqm4w6g" that is JUST the flash game
Whats the best way to insert this into my site?
Below is a general script which will embed your flash movie in a html page, theres several ways to do this but below will work just copy and paste the code on to your html page in the body area.Check the adobe website if you need other parameters or more information.
<object id="yourmovie.swf" width="550" height="450" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" align="middle" bgcolor="#ffffff">
<param name="allowScriptAccess" value="sameDomain" />
<param name="quality" value="high" />
<param name="src" value="http://www.yourwebsite/yourmovie.swf" />
<param name="allowscriptaccess" value="sameDomain" />
<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer" />
<embed id="slots.swf" width="476" height="321" type="application/x-shockwave-flash"src="http://www.yourwebsite/yourmovie.swf"
allowScriptAccess="sameDomain" quality="high" allowscriptaccess="sameDomain"
pluginspage="http://www.macromedia.com/go/getflashplayer" align="middle" bgcolor="#ffffff" />
</object>
To use a link from java my option will be create a button/link thats open another window with the above on that html page

Why do the buttons users could click at the end of embedded YT videos not appearing?

Only the subscribe button appears at the end (along with a display of how many likes/dislikes checked direct on YT). Is there an embed code to get these back so users can vote on my site?
Sample embed code:
<object style="height: 360px; width: 640px">
<param name="movie" value="http://www.youtube.com/v/XXXXXXXXXXXXX?version=3&controls=1&autohide=1&modestbranding=1&rel=0&autoplay=1&showinfo=0&showsearch=0&iv_load_policy=3&border=2&color1=0xB24D7E&color2=0xfff0f5&fs=1&hd=0&feature=player_embedded" /><param name="allowscriptaccess" value="always" /><param name="wmode" value="transparent" /><param name="allownetworking" value="internal" /><embed src="http://www.youtube.com/v/XXXXXXXXXXXX?version=3&controls=1&autohide=1&modestbranding=1&rel=0&autoplay=1&showinfo=0&showsearch=0&iv_load_policy=3&border=2&color1=0xB24D7E&color2=0xfff0f5&fs=1&hd=0&feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" allownetworking="internal" width="640" height="360"></embed></object>
Embedded AS3 player
.If you open http://youtube.googleapis.com/v/_Acr-FWRWXE?autoplay=1,
it's equivalent to AS2 player,
http://youtube.googleapis.com/v/_Acr-FWRWXE?autoplay=1&version=2
However, if you only open http://youtube.googleapis.com/v/_Acr-FWRWXE without parameters(such as autoplay), http://youtube.googleapis.com/v/_Acr-FWRWXE no more version 2, it's version 3 now.
You need version 3(AS3) for display likes/dislikes icon, that's means
http://youtube.googleapis.com/v/_Acr-FWRWXE?version=1234567 or
http://youtube.googleapis.com/v/_Acr-FWRWXE?version=3
You open http://youtube.googleapis.com/v/_Acr-FWRWXE, play at the
end, you copy the embed code, unfortunately the embed code is wrong,
it give you
name="allowScriptAccess" value="always">
src="http://www.youtube.com/v/_Acr-FWRWXE&hl=en_US&feature=player_embedded&version=3"
type="application/x-shockwave-flash" allowfullscreen="true"
allowScriptAccess="always" width="640" height="360">
As you can see, no question mark ? inside
http://www.youtube.com/v/_Acr-FWRWXE&hl=en_US&feature=player_embedded&version=3
, thats means its still version 2, you shoud change to
http://www.youtube.com/v/_Acr-FWRWXE?hl=en_US&feature=player_embedded&version=3
instead.
IFrame embed.
Using www.youtube.com/embed/a6_AHH-A0ks
Hope this help :)

Soundcloud player appears over colorbox in chrome

I'm using colorbox to display images for a website. In Chrome version 11.0.696.65 only when the color box is activated, the soundcloud player appears infront of the displayed image.
I've tried changing the z-index of the colorbox, but with no success. I'm pretty sure this is a new problem with chrome/soundcloud as I wasn't having the problem before.
UPDATE The following code works and might help someone.
#Add transparent mode to youtube
embeded_link.gsub!(/("http:\/\/www\.youtube\.com\/embed\/.{11})(")/,'\1?wmode=transparent\2')
#Add transparent mode to soundcloud
embeded_link.gsub!(/(<object height=".+" width=".+">\s*)(<param name="movie" value="http:\/\/player\.soundcloud\.com\/player\.swf)/,'\1<param name="wmode" value="transparent"></param>\2')
You need to embed your Flash with wmode="transparent" (or opaque).
Here's a snippet with wmode inserted in both the required places.
<object height="81" width="100%">
<param name="wmode" value="transparent"></param>
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F5475496"></param>
<param name="allowscriptaccess" value="always"></param>
<embed wmode="transparent" allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F5475496" type="application/x-shockwave-flash" width="100%"></embed> </object>
See: http://kb2.adobe.com/cps/127/tn_12701.html

rails 3 embed video

I'm trying to embed youtube video.
in the videos db table, i have field called "link".This contains the link of the video.
In Controller Videos, there is just empty method def vidlist, since i'm just trying to display single video.
I have vidlist.html.erb:
<blink>
<h1>Vidlist</h1>
<object width="640" height="385">
<param name="movie" value="<%= Video.first.link %>">
</param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="<%= Video.first.link %>"
type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
</blink>
the link contains this string:http://www.youtube.com/v/KgmeL_xuB0I?fs=1&hl=en_US&rel=0&autoplay=1
In routes .rb, i have uncommented the default route matching.
Then, i started server.Entered localhost:3000/Videos/vidlist
The browser doesn't display anything at all.
and there's nothing in the console too when the server is running
Have you tried using html_safe on the link? This will help ensure that you don't have issues with escape chars etc.

Resources