Hi All
I am creating a Visual Basic program for a Movie datbase, but i want to be able to play a youtube video Via the media player option. I would like the user to paste the link in from youtube into a text box, and click play and the video plays.
I would like to do it, how this guy has done it http://www.youtube.com/watch?v=ABafGneA7mw , but he is using VB 2008. Is there away to do this in VB6

I am pretty new to this,so any help would be great

Thanks Michael

Recommended Answers

All 6 Replies

Is there away to do this in VB6

Yes. there's a way.

You must have Windows Media Player instaled in your computer.

First, add new component ( Windows Media Player)
You can press ctrl+T or Project->Add Component, then select Windows Media Player and press OK.
New component will added to your toolbox. Draw it to your form and also add Textbox to your form.

I'm Using Keypress event in textbox. After user input url in textbox and press enter then it will connecting.

Private Sub URLAddr_KeyPress(KeyAscii As Integer)
Dim VideoAddr As String

VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")

If KeyAscii = 13 Then
    WindowsMediaPlayer1.URL = VideoAddr 
End If
End Sub

This the snapshot :
2ae5ea38a4eb080a021177b50fceda34

Thank you so much, for your help

Hi, i gave it ago, and i didnt work. This is the code that i have got:

Private Sub Command2_KeyPress(KeyAscii As Integer)
Dim VideoAddr As String
VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")
If KeyAscii = 13 Then
    WindowsMediaPlayer1.URL = VideoAddr
End If


End Sub

I have tried adding it to a text box, insest the link and press eneter, but i get an error messgae 424 object needed. Basically i want a textbox to put the link in, and then the user presses a play button. I have uploaded an image of my design.

Thanks in advance

This is code already test and working fine.
I'm using keypress event just for textbox not for the button.
If you want to use button to play it then use button default event (click event) and don't change it with any events like keypress event.
Also please confirm that your textbox name is URLAddr and button name is Command1 to make this working.
I hope you can handle it.

Private Sub Command1_Click()
    Dim VideoAddr As String
    VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")
    WindowsMediaPlayer1.URL = VideoAddr 
End Sub

Awesome, i didnt change the text box name, thanks again for your help

I've tried this and cannot make it work and textbox is set as keypress

Private Sub Command74_Click()
    Dim VideoAddr As String
    VideoAddr = Replace(URLAddr.Text, "/watch?v=", "/v/")
    WindowsMediaPlayer1.URL = VideoAddr
End Sub
commented: Maybe VB6 apps have run their course. Time to move on. +16
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.