hey guys I am makign a media player but how do I get it so that a movie would play on the same form as the buttons are. AS I use MMcontrol hen I play a movie it opens it own window, can I make a picture box and put the movie in that? Thanks!
Printable View
hey guys I am makign a media player but how do I get it so that a movie would play on the same form as the buttons are. AS I use MMcontrol hen I play a movie it opens it own window, can I make a picture box and put the movie in that? Thanks!
Which player are you using? Media Player or Multimedia control?
Multimedia Control.
Ok then you must be shelling the file being played? Can you show some code?
Just a hunch but are you specifying the UsesWindows property in the open command or setting that property?
lol I have no idea, I got this code from another website...
VB Code:
Option Explicit Private path As String Private fname As String Private i As Long '''Code for shutting down stuff '' Code for opening webpages '' Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _ ByVal hwnd As Long, _ ByVal lpOperation As String, _ ByVal lpFile As String, _ ByVal lpParameters As String, _ ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Public Sub UnloadAllForms(AForm As Form) 'This code shuts down all forms and prevents multiple instances ' if any other programs are made, make sure they include this code. Dim frm As Form For Each frm In Forms If frm.Name <> AForm.Name Then Unload frm Set frm = Nothing End If Next Unload AForm Set AForm = Nothing End Sub Function GetFileLocation() As String With CommonDialog .ShowOpen GetFileLocation = .FileName End With End Function Private Sub MMControl1_Done(NotifyCode As Integer) MMControl1.FileName = "" MMControl1.Command = "Close" MMControl1.Command = "Stop" End Sub Private Sub Form_Load() Dim file_name As String file_name = App.path If Right$(file_name, 1) <> "\" Then file_name = file_name & "\" ' txtFilename.Text = file_name & "Gears.avi" ' Prepare the MCI control for AVI video. MMControl1.Notify = False MMControl1.Wait = True MMControl1.Shareable = False MMControl1.DeviceType = "AVIVideo" End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) UnloadAllForms Me End Sub Private Sub Timer1_Timer() Slider1 = MMControl1.Position End Sub Private Sub Image1_Click() txtFilename.Text = GetFileLocation Slider1.Max = MMControl1.Length ' Set the file name. path = txtFilename.Text MMControl1.FileName = txtFilename.Text ' Open the MCI device. MMControl1.Wait = True MMControl1.Command = "Open" ' Play the video. MMControl1.Wait = True MMControl1.Command = "Play" ' Close the device. MMControl1.Command = "Close" MMControl1.FileName = path MMControl1.Command = "Open" MMControl1.Command = "Play" i = InStrRev(Me.MMControl1.FileName, "\") fname = Mid(Me.MMControl1.FileName, i + 1) Me.List1.AddItem fname End Sub Private Sub Image4_Click() MMControl1.Command = "stop" End Sub Private Sub mnuAbout_Click() MsgBox "MHX Mega Media Player by Microhardxce Enterprises." End Sub Private Sub mnuExit_Click() UnloadAllForms Me End Sub Private Sub mnuMore_Click() ShellExecute Me.hwnd, "open", "http://www.geocities.com/nitrogenocide2003/MHXDownloads2.html", vbNullString, vbNullString, ByVal 1& End Sub
Set the UsesWindows =False in your code and see if it helps. Its dependant upon the file type being desired played.
Ok, where abouts in my code would I set that,
[colornavy]In your form_load event.[/color]
Ok i added it, but I get the error variable not defined??
Use this instead of UsesWindows.
But MMControl is buggy or just bad. Coz whole form just hangs when playing AVI. It will response again after AVI playing is finished.Code:MMControl1.hWndDisplay = hWnd
What else could I use?
You could use the Windows MediaPlayer control.
ok I added the compoenent, but how do I get the buttons and commands to work?
Check attachement for simple example i coded for you.
You can change the
to something else of course.Code:wmp.URL = "C:\WINDOWS\CLOCK.AVI"
thank you very much!!
Edit, am I allowed to make this part of a program to be available for download? Will microsoft be mad?
No, as the user will need to have Media Player installed.
So in order for this to work, other people will already need to hav windows media player???
lol
Yes, that a normal fact as you have to signup and register for distribution of their copyrighted program.
what other things of theirs would I have to sing up and register for to distribute programs I made in VB?
Its not just sign up and your in type of thing. You have to be approved and sign a contract etc. Your better off just prompting the user to download from MS and provide the link upon detection that they dont have WMP installed.
So I am allowed to distribute the media player I am making, but as long as I tell them to download windows media player too?
Oh crap, I have made other programs in VB and distributed them, did I have to make a contract for that?
No, you can distribute the control but it will not work without the WMP neing installed as the users system needs the dependancy files and rest of the program to make WMP player work like you see it in your app.
Think of it as with the rest of your program. You need to distribute a vb control in your app but it wont work if you dont also distribute the msvbsm60.dll runtime file. It is just that MS allows the distribution of the vb runtimes as its not an actual complete program but a dependancy file. The WMP is a complete standalone program that you are using a small feature of. Basically automating the WMP program within your app.
Aww I understand now, thanks for clearing that up.
Whatever other programs you have written will not have the same requirements. Its the same legality as if you were using an Access database in your app. Its legal to redistribute the database file you have created and MDAC engine is redistributable so you can access the database via your app without ever showing or displaying the actual GUI of Access because there are alot more files and dependancies that would be needed to run the full Access program. Access the program is NOT redistributable. Each end user needs to have a purchased licensed copy of it in order to view and display any of its GUI and have it work via is GUI front end.
There is an exception to this for Access but I wont confuse you with it :D
Ok so dependencies are alright to include, but you can't redistribute entire programs, makes sense lol.
Out of curiosity, is there a media control that does not need the user to have wmp installed prior to using the app I make?
Dude, ither way you look at it.. Your devloping "software" for Windows, and almost all Windows machines have WMP, maybe not the latest but still WMP. Work with what you have. If not, Google it.Quote:
Originally Posted by Justin M
But not all machines will have it installed on their Windows. But you can redistribute the setup packages with acceptance of your license application.
http://msdn2.microsoft.com/en-us/lib...11(VS.85).aspx