Results 1 to 19 of 19

Thread: Wmp

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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!

  2. #2
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Wmp

    cool! Thanks ill give it a bash.
    wish someone would know the answer to my Q in the mobile development forum... lol

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Wmp

    The WMP control has a Ctlcontrol property that has methods for controlling palyback.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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....

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Wmp

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Wmp

    NOPE, I tried that before

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Wmp

    im also using the active x control. im using WMP 10 SDK

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Wmp

    I've added a WMP control to my form plus four buttons, then added this code:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim ofd As New OpenFileDialog
    3.  
    4.         If ofd.ShowDialog = DialogResult.OK Then
    5.             Me.AxWindowsMediaPlayer1.URL = ofd.FileName
    6.         End If
    7.     End Sub
    8.  
    9.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    10.         Me.AxWindowsMediaPlayer1.Ctlcontrols.play()
    11.     End Sub
    12.  
    13.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    14.         Me.AxWindowsMediaPlayer1.Ctlcontrols.pause()
    15.     End Sub
    16.  
    17.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    18.         Me.AxWindowsMediaPlayer1.Ctlcontrols.stop()
    19.     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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  14. #14
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Wmp

    Quote Originally Posted by Techno
    nope
    play plays the file from the start

    no it doesn't. It resumes from the position where you paused.

    Quote 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

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Wmp

    THAT last code posted works.
    well done and thanks

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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)

  18. #18
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    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

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    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
  •  



Click Here to Expand Forum to Full Width