|
Thread: Wmp
-
Jul 23rd, 2005, 04:39 PM
#1
Thread Starter
PowerPoster
Wmp
Hi!
I have made an application on which you can play audio/video through WMP. However the application launches WMP externally and plays the file.
I was wondering, is there a way I could control it so I can pause/play/stop/forward/reverse the current playing file? or is there a way to do it if I somehow put in the WMP control on the form?
Thanks!
-
Jul 23rd, 2005, 05:39 PM
#2
Fanatic Member
Re: Wmp
If you put the control on a form then you can control its playback with various methods, it also has a property indicating its current state. (can't remember the precise names).
I guess remote-controlling a WMP session is possible, but it would likely be a huge hassle.
Good luck.
btw. you can also use DirectX to display video directly on a form or control.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Jul 23rd, 2005, 05:41 PM
#3
Thread Starter
PowerPoster
Re: Wmp
cool! Thanks ill give it a bash.
wish someone would know the answer to my Q in the mobile development forum... lol
-
Jul 23rd, 2005, 10:42 PM
#4
Re: Wmp
The WMP control has a Ctlcontrol property that has methods for controlling palyback.
-
Aug 18th, 2005, 12:28 PM
#5
Thread Starter
PowerPoster
Re: Wmp
indeed it does, I was playing with the WMP 10 SDK and its amazing how easy it is!
one thing tho, there is no way of resuming a paused file... any ideas?
-
Aug 18th, 2005, 06:11 PM
#6
Re: Wmp
I've never used the control so I haven't tested it, but I would have thought that Ctlcontrol.play() would start playing from the previous position after Ctlcontrol.pause(), and you would have to call Ctlcontrol.stop() to go back to the beginning of the file. Is that not the case?
-
Aug 18th, 2005, 08:55 PM
#7
Thread Starter
PowerPoster
Re: Wmp
nope 
play plays the file from the start
stop stops it
pause pauses the file as is, when pressed again it does nothing....
-
Aug 18th, 2005, 09:13 PM
#8
Re: Wmp
 Originally Posted by jmcilhinney
I've never used the control so I haven't tested it, but I would have thought that Ctlcontrol.play() would start playing from the previous position after Ctlcontrol.pause(), and you would have to call Ctlcontrol.stop() to go back to the beginning of the file. Is that not the case?
I just tested and, as I suspected, play() starts playing from the current position. This means that if you previously called pause(), calling play() will resume playing from the point at which you paused.
-
Aug 19th, 2005, 01:33 AM
#9
Thread Starter
PowerPoster
Re: Wmp
NOPE, I tried that before
-
Aug 19th, 2005, 01:50 AM
#10
Re: Wmp
What can I say? It works for me whether I'm using a WindowsMediaPlayerClass object (no UI) or an AxWindowsMediaPlayer object (ActiveX control).
-
Aug 19th, 2005, 01:50 AM
#11
Thread Starter
PowerPoster
Re: Wmp
im also using the active x control. im using WMP 10 SDK
-
Aug 19th, 2005, 01:59 AM
#12
Re: Wmp
I've added a WMP control to my form plus four buttons, then added this code:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ofd As New OpenFileDialog
If ofd.ShowDialog = DialogResult.OK Then
Me.AxWindowsMediaPlayer1.URL = ofd.FileName
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.AxWindowsMediaPlayer1.Ctlcontrols.pause()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.AxWindowsMediaPlayer1.Ctlcontrols.stop()
End Sub
If I press Button1 and select a music file it starts playing immediately. If I then press Button3 the playback is paused. If I then press Button1 the playback resumes from the point it was paused. Having said all this, given that the ActiveX control has all the regular play, pause, stop, etc. buttons on it, do you really need to call these functions anyway?
-
Aug 19th, 2005, 12:03 PM
#13
Thread Starter
PowerPoster
Re: Wmp
its the same code I have too (play/pause/stop) and yes I do need all these functions otherwise I wouldnt be asking
-
Aug 19th, 2005, 02:36 PM
#14
Fanatic Member
Re: Wmp
 Originally Posted by Techno
nope 
play plays the file from the start
no it doesn't. It resumes from the position where you paused.
 Originally Posted by Techno
pause pauses the file as is, when pressed again it does nothing....
That's right, you have to check wether it's paused or not. This is the code I used in a 'Pause' button's click handler:
Code:
private void button2_Click(object sender, System.EventArgs e)
{
if (this.axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused)
{
this.axWindowsMediaPlayer1.Ctlcontrols.play();
}
else
{
this.axWindowsMediaPlayer1.Ctlcontrols.pause();
}
}
And don't say it doesn't work, because it does.
BTW You better spread out some reps on this thread.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Aug 19th, 2005, 02:43 PM
#15
Thread Starter
PowerPoster
Re: Wmp
lol ill try that code but i stand correct in that if you press the play button it plays from the start regardless if you have previously paused the file or not
but for some reason i still think the code you posted will not resolve the issue but i will of course try it.
if i still have problems, i will upload a video where you guys can see what's happening
-
Aug 19th, 2005, 09:32 PM
#16
Thread Starter
PowerPoster
Re: Wmp
THAT last code posted works.
well done and thanks
-
Aug 20th, 2005, 12:30 AM
#17
Thread Starter
PowerPoster
Re: Wmp
one last thing, hopefully.
I am trying to set the screen size to full screen (this.theMediaPlayerObj.fullscreen = true); and it gives me a "catastropic Interop ComException"!
huh? lol
Error #:-2147418113 System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure
at WMPLib.IWMPPlayer4.set_fullScreen(Boolean pbFullScreen)
at AxWMPLib.AxWindowsMediaPlayer.set_fullScreen(Boolean value)
-
Aug 20th, 2005, 04:40 AM
#18
Fanatic Member
Re: Wmp
You cannot set that property during runtime, only designtime.
"so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman
-
Sep 4th, 2005, 10:11 PM
#19
Thread Starter
PowerPoster
Re: Wmp
is there a way to get rid of the standard WMP error messages that are displayed when an error happens (like error reading file or could not find appropriate decompressor etc..)?
I have made an event handler which handles the Media_Error but thats it... even handling it from there doesnt seem to "hide"/"close" the standard error messages from appearing
any ideas?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|