Supply the url and have the form stream the youtube flv movie.
Also google videos/aol vids, etc -> mainstream online videos.
Is this possible ?
Printable View
Supply the url and have the form stream the youtube flv movie.
Also google videos/aol vids, etc -> mainstream online videos.
Is this possible ?
you can just put a webbrowser control on the form and navigate to the url to view the web page.
Thanks but not the whole page: just the embed code so that just the movie will size to form size, show & play...
Code:<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/k66epna2Sss&hl=en"></param><embed src="http://www.youtube.com/v/k66epna2Sss&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>
use vb code to add this sourcecode to your webbrowsercontrol. Next use the DOM option in vb.net to change value of the param!
have you visited the youtube developer pages to see if theres anything there to help you=
Tried some time ago, only found support for PHP, ASP & Java.Quote:
Originally Posted by Atheist
Tried again today and found this VB.NET Version of Google Data API SDK
Anyone with more knowledge than me , wanna try this out with me ?
Never done this. Can you please give me a sample of how it's coded ?Quote:
Originally Posted by stef-o
bmahler was on the right track. You can simply load up JUST the html of the object you want to view (in this case a flash video). You can adjust the height and width prior to loading the HTML so the video can render at whatever size you want.
In this example code, it assumes there is just a webbrowser control on the form called Webbrowser1. It grabs the height and width of the browser control (which by default is docked).
So just start a new project, add a webbrowser control to the form, then go into the code and erase any code in there, and paste this:
Code:Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'HTML STRING WE WANT TO LOAD TO BROWSER CONTROL
'NOTICE THE DOUBLE "" AROUND ALL THE PARTS INSIDE
'THE STRING THAT REQUIRE SINGLE "
Dim HTMLString As String = "<html><body>" & _
"<object width=""{width}"" height=""{height}"">" & _
"<param name=""movie"" value=""http://www.youtube.com/v/k66epna2Sss&hl=en""></param>" & _
"<embed src=""http://www.youtube.com/v/k66epna2Sss&hl=en"" type=""application/x-shockwave-flash"" width=""{width}"" height=""{height}"">" & _
"</embed></object></body></html>"
'WE REPLACE THE WIDTH AND HEIGHT CONSTANTS IN THE ABOVE STRING
'WITH THE PHYSICAL CURRENT SIZE OF THE BROWSER CONTROL IN THE FORM
HTMLString = HTMLString.Replace("{width}", WebBrowser1.Width.ToString)
HTMLString = HTMLString.Replace("{height}", WebBrowser1.Height.ToString)
'LOAD THE HTML INTO THE BROWSER
WebBrowser1.DocumentText = HTMLString
End Sub
'BROWSER SIZE CHANGED (BECAUSE FORM SIZE CHANGED)
Private Sub WebBrowser1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser1.SizeChanged
'MAKE SURE DOCUMENT IS LOADED BEFORE WE DO ANYTHING
'(BECAUSE THIS EVENT FIRES WHEN FORM IS CREATED)
If WebBrowser1.Document Is Nothing Then Return
'GRAB THE EMBED ELEMENT FROM THE HTML
Dim objectCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("embed")
'MAKE SURE WE GOT AT LEAST 1 EMBED ELEMENT RETURNED
'IN THE CASE OF THIS EXAMPLE, THE COUNT SHOULD ALWAYS BE 1
If (objectCollection IsNot Nothing) AndAlso _
(objectCollection.Count <> 0) Then
'GRAB THE SINGLE <EMBED> ELEMENT
Dim movieElement As HtmlElement = objectCollection.Item(0)
'ADJUST HEIGHT AND WIDTH ACCORDING TO NEW SIZE
movieElement.SetAttribute("width", WebBrowser1.Width.ToString)
movieElement.SetAttribute("height", WebBrowser1.Height.ToString)
End If
End Sub
End Class
Kleinma, this is why you are MVP. Thanks.
I have replaced the code in form1 with yours.
But all I get is a form with a blank webbrowser ??? No movie is loaded. And yes, my internet is connected.
Not sure, but here is the original source code from my app. If this doesn't work for you either, then there is something wrong with your PC or VS
All right :) I tried it on another pc and it works fine.
Kleinma, is there any way to get this embedded movie to autostart ? or start with a form1 button click.
Also when mouseover on the video all the youtube shortcuts, etc come up which (in this case) interferes with movie watching.
Is there any way to forbid mouseover on webbrowser1
what if the user wants to pause or rewind the video though? they cant if you have blocked the mouseover event
append autoplay=1 to the URL so it looks like:
http://www.youtube.com/v/k66epna2Sss&hl=en&autoplay=1
Do this for both URLs in the HTML.
As for not showing the shortcuts on mouse over, I don't know how you could prevent that. I don't think there is a direct way, short of something that would be considered a hack. I have 1 idea how you could do it, so I will let you know if I think it is something that works properly.
I would prefer to have my own play/rew/stop buttons on the formQuote:
Originally Posted by chris128
well good luck getting those buttons to work properly with the youtube video...
Works great thanks.Quote:
Originally Posted by kleinma
What I'd like to do is control the embedded youtube video via my own form buttons.Quote:
Originally Posted by kleinma
The webbrowser would become something like a picturebox, ie: display only without allowing the user to click the webbrowser and go to other urls, links from there. I guess what we're doing is creating our own youtube/flv player on a form.
Appreciate the help.
come on now, we're dealing with a webbrowser here.;)Quote:
Originally Posted by chris128
PLAY is easy. STOP is easy. REW is webbrowser reload. There is no FF
All I'm trying to do is deny the user mouseover or webbrowser click. Do it through my buttons/UI...
why is play easy? its easy the first time, but what if the user wanted to pause and then continue? If i remember rightly, the youtube video player is just a flash object and I dont know how you can interact with flash via VB.NET (although there is thread on this forum on the first page asking the question about VB with Flash so maybe you could take a look there)Quote:
Originally Posted by Xancholy
Oh and REW isnt webbrowser reload because thats just stopping the whole video and playing it from the start again, what if it was a 20 minute video and the user just wanted to go back 1 minute..
How about subclassing the HWnd ?Quote:
Originally Posted by kleinma
Code:Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim s As SubclassHWND = New SubclassHWND()
s.AssignHandle(Me.Webbrowser1.Handle)
' Now s should be listening to the webbrowser's messages.
End Sub
Code:Public Class SubclassHWND
Inherits NativeWindow
Private Const WM_LBUTTONDOWN As Integer = &H201
Private Const WM_LBUTTONDBLCLK As Integer = &H203
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
' do whatever custom processing you need for
Select Case m.Msg
Case WM_LBUTTONDOWN
' Disable mousedown/click
Case WM_LBUTTONDBLCLK
' Disable double click
Case Else
'It is important to pass unhandled messages back to the default message handler.
MyBase.WndProc(m)
End Select
End Sub
End Class
I see you just came accross the same thing on google that I did then :P
We can't do the impossible. So, REW is rewind completely. Stop is STOP completely. Play is play from beginning. I think we agree on this.Quote:
Originally Posted by chris128
But I got there before you... :wave: naw, I asked for this solution for another control elsewhere, so it's fresh in my mind.:DQuote:
Originally Posted by chris128
why is that impossible :S You can rewind a video on youtube by dragging the timeline blob back a bit so if you can find out how to interact with the youtube flash player then you can do the same thing programmatically.Quote:
Originally Posted by Xancholy
ahh, I get you now. You like impossible. I'm all ears. Let's control youtube bro. Hook them up to our own trackbar
Well.... I still think its going to be really hard but I'm just saying if you could do play/pause then rewind is going to require the same method.
Have you looked at this thread yet? http://www.vbforums.com/showthread.php?t=523975
Well, I just tried the webbrowser subclassHWND and it doesn't seem to respond to this method.
For the most control, you would want to write your own Flash Player and use the YouTube APIs to feed it. Doing everything via a web browser will limit you.
Are you referring to this API, robDogg ?
Quote:
Originally Posted by Xancholy
Yes and did you notice that in the link is an ASP.NET example too?
I see the example but cannot seem to open it. Is there an asp.net >vb.net converter I could use ?
Open the files with notepad but there is no converter for asp.net to vb.net as the html wouldnt convert but the vb code is just about the same.
You can't convert an ASP.NET application into VB.NET. The front end is ASP.NET/HTML and the codebehind contains the logic that you want.
I've downloaded & installed the sdk and I'm looking in the folder:
C:\Program Files\Google\Google Data API SDK\Sources\Samples\YouTubeSample
I'm feeling a little blind. I'm looking at the files using notepad and not seeing the how-to-play-youtube-videos code:confused:
You are not going to find a procedure that says that. Its a complete project. You will fine the YouTube APIs being referenced and that should show/direct you what all is needed.
Hi, i've been thinking about this; is it possible to just use a normal webbrowser object but play audio or/and video on a normal player like media player object then use its controls like play,pause e.t.c (buffer load the video or something ). Am trying to play youtube videos too
dex3844, you should create your own thread instead of digging up a 4 year old thread.
But to answer your question... if you want to play YouTube videos on your form, then you can use the ShockWave Flash Player (assuming the uploader has enabled embedding). You don't have to mess around with the WebBrowser control.
In VS2010 right-click somewhere on your Toolbox and select "Choose Items...".
Go to the "COM Components" tab, tick "ShockWave Flash Object" and click on "OK".
You now have "ShockWave Flash Object" in your Toolbox and drag it onto the form.
Change the YouTube url from this: http://www.youtube.com/watch?v=eOrNdBpGMv8
To this: http://www.youtube.com/v/eOrNdBpGMv8
Then use the following code to play the video. You will get the YouTube player, including the buttons, etc.
vb.net Code:
AxShockwaveFlash1.LoadMovie(0, "http://www.youtube.com/v/eOrNdBpGMv8")
thank you very much for your reply ..this will help me loads - by the way can it be done in vb 2008 ?
Yes, you can. As far as I know it works exactly the same.
Ok thank you very much