Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with Mediaplayer object

Status
Not open for further replies.

SLider3

Programmer
Jun 17, 2003
56
PT
I´m trying to make a video (also audio) player. For this i´m using the object mediaplayer, but i´m having some problems.

At the moment my player only have the common buttons (play, stop, etc) and a Panel where the video is displayed.

1) Now i´m trying to implement a trackbar. For this i use the TrackBar object (is there any other better?).
In the timer function i put something like this (to move the trackbar slider with the video):
TackBar->Position=MediaPlayer->Position*100/MediaPlayer->Length;
And in the OnChange event of Trackbar i put this:
MediaPlayer->Position = (MediaPlayer->Length * TrackBar->Position)/100;
But this code doesn't work because when the movie is playing (timer function) the trackbar is moving (OnChange) and then the OnCnahge event is executed (i only want this to happen when i move the slider). What should i do?

2) I want to know how can i resize my Panel with the dimensions of the video image? How can i make a fullscreeen option?

3) My player only handle avi files, but i want it to play other format files like .mov and also .mkv (dont know if you heard about this one). But when i try to play other format files i always get this message: "Cannot determine the devide type from the given filename extension.". How can i solve this?

4) How can i change the speaker volume?


Hope you can help me. :)
Thanks in advance.
 
First of all, don't use mediaplayer from builder, it sucks. Import ActiveX Windows Media Player and use it instead (Component->Import ActiveX Control...).
 
@mironto
Can you give me some example code?

Btw, i think mediaplayer from builder is enought for what i want to do, so i would like to know the answers to the questions i made above.

;-)
 
Hi!

Answers:

1) Now i´m trying to implement a trackbar. For this i use the TrackBar object (is there any other better?).
In the timer function i put something like this (to move the trackbar slider with the video):
TackBar->Position=MediaPlayer->Position*100/MediaPlayer->Length;
And in the OnChange event of Trackbar i put this:
MediaPlayer->Position = (MediaPlayer->Length * TrackBar->Position)/100;
But this code doesn't work because when the movie is playing (timer function) the trackbar is moving (OnChange) and then the OnCnahge event is executed (i only want this to happen when i move the slider). What should i do?

SOLUTION:
- Change the Timer event code to:

TrackBar->OnChange=NULL;
TrackBar->Position=MediaPlayer->Position*100/MediaPlayer->Length;
TrackBar->OnChange=TrackBarChange; //or yer handler

2) I want to know how can i resize my Panel with the dimensions of the video image? How can i make a fullscreeen option?

SOLUTION:
To change dimensions, use DisplayRect property, which works with panel client coordinates.

//Panel OnResizeHandler :
MediaPlayer->DisplayRect=Rect(0,0,Panel->Width,Panel->Height);

To implement a full screen option, you should create a top most frameless Form.

//Forn OnShow handler (MediaPlayer address passed in Form's constructor) :
MediaPlayer->Display=this;
MediaPlayer->DisplayRect=ClientRect;

3) My player only handle avi files, but i want it to play other format files like .mov and also .mkv (dont know if you heard about this one). But when i try to play other format files i always get this message: "Cannot determine the devide type from the given filename extension.". How can i solve this?

The TMediaPlayer is a simple MCI wrapper. That means it has very limited and outdated functionality. If you want to play MPEG2, MOV, DivX, XViD or any newer files, you should get experienced with DirectShow. You can download the SDK from MSN.

4) How can i change the speaker volume?
There is a way but i cant remember. Check the Windows SDK for MCISendCommand function or something like that. You should pass the MediaPlayer DeviceID property to that Windows API function somehow.

Just for the record, if you wanna play media in Windows you need DirectShow.

unbornchikken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top