Solved

Code to run video on WindowsMediaPlayer component on a VB 6 form

Posted on 2004-08-04
13
659 Views
Last Modified: 2008-01-09
I have the following code to run video by first launching "WindowsMediaPlayer exe file installed on the computer" and then running .wmv file:

Public Function StartDoc(ByVal FileName As String, Optional CommandLine As String = "")

 StartDoc = ShellExecute(0 &, "Open", FileName, CommandLine, VbNullString, 1)

End Function
----
StartDoc "C\MyFolder\1.wmv"
-----
Q1. How can I revise above code to open my 1.wmv file through the control on the form (WindowsMediaPlayer component on a VB form)?

Q2. What is the code to switch video play to "WindowsMediaPlayer exe file installed on the computer" through a double-click action (directly on the component on the form).

Regards,

Mike
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11722580
There is a Windows Media Player OCX that is placeable on the control.  You can add the ActiveX control by adding it through the Add Components dialog.

Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11722737
First a added the ActiveX control to tool box.  Then, I droped it on my form.  Now, I have "C:\MyFolder\1.wmv".  Please give me step by step direction from this point on.

Mike
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 11722801
Mike,

try like:

...
MediaPlayer1.FileName = "c:\test.wmv"
    MediaPlayer1.Play
...
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 19

Accepted Solution

by:
Shauli earned 500 total points
ID: 11722829
'Lets say you load it form command button, then:
Private Sub Command1_Click()
    WindowsMediaPlayer1.URL = "C:\MyFolder\1.wmv"
End Sub

S
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11723187
Wow.  This is great Shauli.  It works wonderfully.  Actually, I am us key press event to run the video (v or V).  When the video finishes, the image of last frame from the video stays on the form.

Q1. How do I clear it (the image of last frame from the video)?
Q2. Becuase ther is no close button for the video control, what will be the code to stop the video also clear the last frame image discussed above (I will us S or s key press to do that.  Also, I may a a button to click on it).

Furthermore, on doubl-click the screen fills the entire monitor.  This is so good.
----------

 ryancys,

MediaPlayer1.FileName = "c:\test.wmv"    <-- gave me an error (.Play isn't available through intelisense either.  I am in VB 6)
 MediaPlayer1.Play                                  <-- I was exited about command .Play thinking there might be .StopPlay or something similar for me to use it.

Regards,

Mike
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 11723288
To stop the movie, we can try like:

MediaPlayer1.Stop

FYI, i use M$ Media Player included from References (msdxm.ocx)
0
 
LVL 19

Expert Comment

by:Shauli
ID: 11724793
'To stop AND clear use the line below:
WindowsMediaPlayer1.Close

'The player clears itself once it finishes to play the video. So all that left is to clear if it was paused by the user, using the integrated pause button. For that you can use the line above as weel. As you will need to close the open url anyway.

S

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11725936
Rust never sleeps, but I do  The question just goes on without you.   Just kick it and watch it go:)

Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11729725
Shauli,

When user makes cerain selection on the vb form, a lable becomes visible stating:

"Hit S to start video."    'of course when there is a video avaiable for the selection
-------
Via S keypress, video starts.  Upon S keypress, the lable changes to:

"Hit Q to quit video."

This works nicely.  "S" keystrok starts the video with "Pause" button on.
-------------
On WindowsMediaPlayer1, we also have "Play/ Pause" and "Stop" Buttons

Q3.  What is the code to "Pause" via a keystrok "P" not by click on the pause button (code to go to Keypress event of the form).  
Q4.  What is the code to "Play" via a keystrok "P" (second P strok) not by click on the play button (code to go to Keypress event of the form, I will need also to detect whether the video is playing or pause at the moment).

Do you want me post these items in a new question?

Regards,

Mike
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11729846
That's it, just totally ignore my assistance:)

Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11729932
Hi Bob,

Do you have time to help me with Q3 and Q4?  I will post a new question for it.  Please note that the response fro Shauli was what worked for me.  

Regards,

Mike
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11729970
I love to have fun with people.  It's always a race to see who get there first.  It's all about finding the right answer:)

Generally, it is acceptable practice to only ask one question at a time.  So my suggestion would be to create a new question for Q3 and Q4.

Bob
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 11730670
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month6 days, 13 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question