YouTube Viewer ![Visual Basic]
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
4 posts
Page 1 of 1
Just a very basic YouTube Viewer tutorial
you require Adobe flash player( wich most users have )
lets start with making a project
![Image]()
then right click your toolbox and click "Choose Items"
![Image]()
After the "Choose Toolbox items " box is loaded , go to COM components and search for "Shockwave flash object" , check it and click "ok".
![Image]()
ok now the ShockWave flash object should be in our toolbox. Add a Shockwave flash object to your form and name it "swf" , also add a textbox and name it "txt"
![Image]()
after you renamed them just add some code.
declare your final url ( that is the url that gives you the ability to play the movie in a swf object)
add a subroutine that converts the original youtube URL to the embed url (for example : "http://www.youtube.com/watch?v=tWkOURXLO8c") and add a ByVal thingy so your app knows what the original url is.
or the complete code with notes :
![Image]()
Thats it donate by downloading my project + rep me up if u like it please cooll;

you require Adobe flash player( wich most users have )
lets start with making a project

then right click your toolbox and click "Choose Items"

After the "Choose Toolbox items " box is loaded , go to COM components and search for "Shockwave flash object" , check it and click "ok".

ok now the ShockWave flash object should be in our toolbox. Add a Shockwave flash object to your form and name it "swf" , also add a textbox and name it "txt"

after you renamed them just add some code.
declare your final url ( that is the url that gives you the ability to play the movie in a swf object)
Code: Select all
Dim urlfinal As String
add a subroutine that converts the original youtube URL to the embed url (for example : "http://www.youtube.com/watch?v=tWkOURXLO8c") and add a ByVal thingy so your app knows what the original url is.
Code: Select all
Now lets make a Uri to check if the host is Youtube and not Metacafe or something
Sub GenerateURL(ByVal YoURL As String)
Code: Select all
Check if the host != youtube
Dim tube As New Uri(YoURL)
Code: Select all
But if the url is valid , continue converting.
If Not tube.Host = "www.youtube.com" Then
MsgBox("The url is not valid")
Code: Select all
Now add something to let your swf know what it needs to play
Else
If YoURL.Contains("watch?v=") Then
'Make the url an embed url by replacing some things.
urlfinal = YoURL.Replace("watch?v=", "v/")
End If
End If
Code: Select all
and ofcourse , don't forget to close the sub
swf.Movie = urlfinal
Code: Select all
now search for your keydown handler of your textbox and let it continue when enter is pressed
End Sub
Code: Select all
Private Sub txt_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt.KeyDown
'When typing and pressing Enter , the youtube video will appear/generate
If e.KeyCode = Keys.Enter Then
GenerateURL(txt.Text)
End If
End Sub
or the complete code with notes :
Code: Select all
Final :Public Class Form1
'After converting this will be your final URL
Dim urlfinal As String
Sub GenerateURL(ByVal YoURL As String)
'Command to generate the url
Dim tube As New Uri(YoURL)
'Check if the url is from youtube
If Not tube.Host = "www.youtube.com" Then
'Give an error
MsgBox("The url is not valid")
Else
'if the url is valid , continue converting
If YoURL.Contains("watch?v=") Then
'Convert the original URL to a embed URL
urlfinal = YoURL.Replace("watch?v=", "v/")
End If
End If
' Show the embed Movie
swf.Movie = urlfinal
'Just for some extra , show the finalURL in your form
Me.Text = urlfinal
End Sub
Private Sub txt_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt.KeyDown
'When typing and pressing Enter , the youtube video will appear/generate
If e.KeyCode = Keys.Enter Then
GenerateURL(txt.Text)
End If
End Sub
End Class

Thats it donate by downloading my project + rep me up if u like it please cooll;
You do not have the required permissions to view the files attached to this post.
Lewis wrote:This has been posted before.. But good work :DDDbut everyone uses a browser wich is bad...
yea i made one where it was a media player
yours is still better
yours is still better
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023