• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

opening a windows media file from VB

what is the quickest/easiest way to open a
Windows Media file (mpeg, avi)
from whithin Visual Basic?

0
system
Asked:
system
  • 4
  • 2
  • 2
  • +3
1 Solution
 
AzraSoundCommented:
Project -> Components and select Windows Media Player

Set the FileName property to point to the file to play.
0
 
Suat OzgurWeb / Application DeveloperCommented:
shell ("start c:\somefolders\file.avi",1)

suat
0
 
Suat OzgurWeb / Application DeveloperCommented:
sorry

response=shell ("start c:\somefolders\file.avi",1)

But this will work if you have a default player for this. And this way is just start that application to run avi file. To play it in your application (i think you ask that:)) then AzraSound suggested easiest way.

'Hi Azrasound, nice to meet you again.

Regards.
suat
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
AzraSoundCommented:
Hey smozgur  :-)
0
 
ArkCommented:
If you don't want to use control , use mciSendString API instead. Take a look at http://blackbeltvb.com/free/mcisamp.htm for sample

Cheers
0
 
systemAuthor Commented:
I should have elaborated further.

The program will be running of a CD, and the path to
the video file will be relative to the drive letter,
on the specific computer (i.e. D, E, F, etc)

Is there a way to place the path to the video
somefolders\file.avi" without the drive letter?

By the way, I actually want to launch WMP not embed the video into the application, so smozgur had the right idea.


0
 
ArkCommented:
Use App.Path:

Shell "Start " & App.Path & "\somefolder\file.avi"

BTW, if you're speaking about AVI, take a look on my sample at http://www.freevbcode.com/ShowCode.Asp?ID=3185 for playing AVI files

Cheers
0
 
Suat OzgurWeb / Application DeveloperCommented:
You can use a file open dialog control (common dialog) then you can use shell function like below (cmdlg1 is the common dialog control name)

response=shell ("start " & cmdlg1.filename, vbHide)

Now your application runs without need to change code. You can also force cmdlg1 to open in CD as default (checking CD drive in system then setting InitDir property to drive root like this; cmdlg1.InitDir="D:\" to run cmdlg1 in D drive).

Suat

0
 
Suat OzgurWeb / Application DeveloperCommented:
But this way would run by user select action. If your file name and folder (not drive letter, folder. Because you can find the CD drive letter but if path information doesnot exist then your application would have to do a search.)

If your application runs from CD then Ark has the right focus. You can set the avi path info by using App.Path property. Because if your application is running from CD then App.Path will retrieve drive letter as CD drive letter. So you just need to put avi file into application folder (or in a subfolder in application folder; App.Path & "\aviFolder\filename.avi" also works.)

Suat


0
 
DanRollinsCommented:
Hi system,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept smozgur's comment(s) as an answer.

system, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
NetminderCommented:
Per recommendation, force-accepted.

Netminder
CS Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now