Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT] Embedding youtube videos into a windows form

So you want to embed youtube videos into your form, well read on

Step One, the form
Needless to say, open visual studio (or any of the express versions), and create a new windows form application in the language of your choice.

in the toolbox, find the components tab
[img]http://img688.imageshack.us/img688/2964/flash1u.jpg[/img]

right click the tab, and click on "Choose Items"
[img]http://img33.imageshack.us/img33/5053/flash2ny.jpg[/img]

go to "Com components" and check the box next to "shockwave flash object", than click "OK"
[img]http://img27.imageshack.us/img27/7563/flash3w.jpg[/img]

Create a form that looks like this:
[img]http://img607.imageshack.us/img607/466/flash4.jpg[/img]
with one shockwave flash object, one textbox (txtlink), and one button

and we are done the form🤗

Step Two, the code
the movie property is what determines the video played by the shock wave flash object.

so, you would think that the obvious step is to double click the button, and use the following code:
Code
AxShockwaveFlash1.Movie = txtlink.Text

however, it will not work.
Why? because this is the link you get from youtube:
Code
http://www.youtube.com/watch?v=kq6HRE0wtYI

but the component wants links like this:
Code
http://www.youtube.com/v/kq6HRE0wtYI

notice how the "watch.php" have been removed, and the "=" replaced with a "/"

instead, double click the button, and paste the following code:
Code
Dim linkportions() As String
  If (txtlink.Text.IndexOf("youtube") <> -1) And (txtlink.Text.IndexOf("watch?v=") <> -1) Then
    linkportions = Split(txtlink.Text, "watch?v=")
    AxShockwaveFlash1.Movie = linkportions(0) & "v/" & linkportions(1)

  Else
    MessageBox.Show("Please enter a valid link")
  End If

So how does this do?

Code
Dim linkportions() As String

creates an array called linkportions()

Code
If (txtlink.Text.IndexOf("youtube") <> -1) And (txtlink.Text.IndexOf("watch?v=") <> -1) Then
checks if the link is valid, it does that by checking if the input contains "youtube" and "watch?v="

if the link is valid:
Code
linkportions = Split(txtlink.Text, "watch?v=")
it splits the link into
Code
http://www.youtube.com/
and
Code
kq6HRE0wtYI

Code
AxShockwaveFlash1.Movie = linkportions(0) & "v/" & linkportions(1)
this sets the Movie property into an acceptable like, like this:
Code
http://www.youtube.com/v/kq6HRE0wtYI

Now if the link is incorrect, it simply displays a message box saying
"Please enter a valid link"

and how we are done!🤗🤗🤗
[img]http://img12.imageshack.us/img12/6590/flash5d.jpg[/img]

thanks for reading!🤝
thanks for this, can come in handy!
Or, just add a webbrowser, get the YouTube URL:
Code
http://www.youtube.com/watch?v=QH2-TGUlwu4
And remove the
Code
watch?v=
Then add
Code
/v/
And we have:
Code
http://www.youtube.com/v/QH2-TGUlwu4

Works just as good. But good job on tutorial.
This could be usefull for auto video viewer programs such as viewet and vagex to decrease the loading time.
I coded one of these in vb6 a long time ago.

Just wanted to point out you can play flash games with it aswell as play videos. Or anything else that uses flash.
(Aug 4, 2011 05:01 PM)I.V Wrote:  Or, just add a webbrowser, get the YouTube URL:
Code
http://www.youtube.com/watch?v=QH2-TGUlwu4
And remove the
Code
watch?v=
Then add
Code
/v/
And we have:
Code
http://www.youtube.com/v/QH2-TGUlwu4

Works just as good. But good job on tutorial.

No, I want to make it clear to everyone that WebBrowsers are shit and should not be used.
(Aug 4, 2011 08:23 PM)Deceptive Wrote:  No, I want to make it clear to everyone that WebBrowsers are shit and should not be used.
Wow, chill your nuts little boy. There is no need for you to jump on the bandwagon for those idiots that do not know the uses for a WebBrowser.

Only because you've read a WebBrowser is bad, you immediately start posting stuff like this about it? Let me tell you, there is so much a WebBrowser can do, which I can guarantee you that you will never be able to do with anything. And that's a deal.

Before jumping to conclusions, and thinking you're pro because you found about a new component, please do think about what you're saying.

(Aug 4, 2011 08:23 PM)Deceptive Wrote:  No, I want to make it clear to everyone that WebBrowsers are shit and should not be used.

Yes, if the developer is an obvious dumb ass and can't use other VB.NET webbrowsers such as WebKite, Gecko and etc... Just making it clear to every one as well.

Not to say IE 9 is actually pretty good now days. 🙂
(Aug 4, 2011 08:31 PM)SpK Wrote:  Wow, chill your nuts little boy. There is no need for you to jump on the bandwagon for those idiots that do not know the uses for a WebBrowser.

Only because you've read a WebBrowser is bad, you immediately start posting stuff like this about it? Let me tell you, there is so much a WebBrowser can do, which I can guarantee you that you will never be able to do with anything. And that's a deal.

Before jumping to conclusions, and thinking you're pro because you found about a new component, please do think about what you're saying.

I do think about what I'm saying. I am chill as well, from what I've seen, people use WebBrowsers for YouTube Bots, Shell Booters or fail to use them all together. There is a lot of things the default WebBrowser does not contain that it should, that's why most prefer to use GeckoFX or that other one I can not remember at this time.
(Aug 4, 2011 08:31 PM)SpK Wrote:  Wow, chill your nuts little boy. There is no need for you to jump on the bandwagon for those idiots that do not know the uses for a WebBrowser.

Only because you've read a WebBrowser is bad, you immediately start posting stuff like this about it? Let me tell you, there is so much a WebBrowser can do, which I can guarantee you that you will never be able to do with anything. And that's a deal.

Before jumping to conclusions, and thinking you're pro because you found about a new component, please do think about what you're saying.

Oh no, don't worry.. The reply was specifically to me. He does not likes me for reason which I yet do not know. I have PM him asking for what I have done wrong but he ignores me.

Thank you though for the support.
(Aug 4, 2011 08:34 PM)Deceptive Wrote:  I do think about what I'm saying. I am chill as well, from what I've seen, people use WebBrowsers for YouTube Bots, Shell Booters or fail to use them all together. There is a lot of things the default WebBrowser does not contain that it should, that's why most prefer to use GeckoFX or that other one I can not remember at this time.
If you did not know GeckoFX is also referred to as a WebBrowser control.

(Aug 4, 2011 08:35 PM)I.V Wrote:  Oh no, don't worry.. The reply was specifically to me. He does not likes me for reason which I yet do not know. I have PM him asking for what I have done wrong but he ignores me.

Thank you though for the support.
Hey retard, if you had something called a brain in your skull, my quote was to the OP, and the post was before yours.
(Aug 4, 2011 08:40 PM)SpK Wrote:  If you did not know GeckoFX is also referred to as a WebBrowser control.

Hey retard, if you had something called a brain in your skull, my quote was to the OP, and the post was before yours.

If you would carefully read what I wrote, I'm with you, and I was actually defending you. Sorry if it did not sound like that. 🤝
(Aug 4, 2011 08:40 PM)SpK Wrote:  If you did not know GeckoFX is also referred to as a WebBrowser control.

Hey retard, if you had something called a brain in your skull, my quote was to the OP, and the post was before yours.

I'm sorry for not constantly checking the date on a post. ._.?
(Aug 4, 2011 08:44 PM)Deceptive Wrote:  I'm sorry for not constantly checking the date on a post. ._.?

You seem lost. That reply about the 'no brain' was to me. lol...
(Aug 4, 2011 08:50 PM)I.V Wrote:  You seem lost. That reply about the 'no brain' was to me. lol...

Fuck. To lazy to comprehend all these posts to multiple people at the same time.

/Thread


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by PanksJul 12, 2021 12:15 AM 2 169 Jul 12, 2021 12:15 AM
Last Post: CheesyBread
[Shell] by Emre_Jan 12, 2021 11:16 PM 0 141 Jan 12, 2021 11:16 PM
Last Post: Emre_
[.NET] by HardStoNJan 31, 2019 12:05 AM 5 302 Jan 31, 2019 12:05 AM
Last Post: 0xDEAD10CC