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:
however, it will not work.
Why? because this is the link you get from youtube:
but the component wants links like this:
notice how the "watch.php" have been removed, and the "=" replaced with a "/"
instead, double click the button, and paste the following code:
So how does this do?
creates an array called linkportions()
checks if the link is valid, it does that by checking if the input contains "youtube" and "watch?v="
if the link is valid:
it splits the link into
and
this sets the Movie property into an acceptable like, like this:
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!🤝
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.Texthowever, it will not work.
Why? because this is the link you get from youtube:
Code
http://www.youtube.com/watch?v=kq6HRE0wtYIbut the component wants links like this:
Code
http://www.youtube.com/v/kq6HRE0wtYInotice 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 IfSo how does this do?
Code
Dim linkportions() As Stringcreates an array called linkportions()
Code
If (txtlink.Text.IndexOf("youtube") <> -1) And (txtlink.Text.IndexOf("watch?v=") <> -1) Thenif the link is valid:
Code
linkportions = Split(txtlink.Text, "watch?v=")Code
http://www.youtube.com/Code
kq6HRE0wtYICode
AxShockwaveFlash1.Movie = linkportions(0) & "v/" & linkportions(1)Code
http://www.youtube.com/v/kq6HRE0wtYINow 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!🤝

