geonaf Posted March 3, 2003 Posted March 3, 2003 Hello again!!! How can I use windows media player to play music files(mp3 etc.) and videos with an VB NET application. First I add a reference of Windows media player to my application (Project->add->reference->COM->Windows media player), and after that???? Thanks a lot!! Quote
AndreRyan Posted March 4, 2003 Posted March 4, 2003 Set up an OpenDialogBox Control to open files and set them up 'Once the box closes: WindowsMediaPlayer1.URL = MyOpenDialogBox.FileName WindowMediaPlayer1.Play Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
geonaf Posted March 4, 2003 Author Posted March 4, 2003 It doesn't work... Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click Dim windowsmediaplayer As New MediaPlayer.MediaPlayer() OpenFileDialog1.DefaultExt = ".mp3" OpenFileDialog1.AddExtension = True OpenFileDialog1.Filter = "mp3 files|*.mp3" If OpenFileDialog1.ShowDialog() = DialogResult.OK Then windowsmediaplayer.Open(OpenFileDialog1.FileName) windowsmediaplayer.Play() End If End Sub ps:I have added a reference (media player) error message: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication11.exe Additional information: Exception from HRESULT: 0x800A0005 (CTL_E_ILLEGALFUNCTIONCALL). please help with details!!!!!!!, tyvm Quote
firebeard Posted July 17, 2005 Posted July 17, 2005 Same problem I have the same problem as Geonab above. Is there a way around it? Cheers Firebeard Quote
Wraith Posted July 17, 2005 Posted July 17, 2005 I have the same problem as Geonab above. Is there a way around it? Cheers Firebeard Install the managed directX runtimes and use Microsoft.DirectX.AudioVideoPlayback.Audio instead of media player. Quote
firebeard Posted July 17, 2005 Posted July 17, 2005 How? Thanks for the tip Wraith. I've tried adding references to the DirectX runtimes, but I can't find them! Do they get installed as standard, or should I be downloading them? Quote
firebeard Posted July 17, 2005 Posted July 17, 2005 Fixed that bit - now another question Hello again Right, I got details on how to set up the MediaPlayer control as part of a form from the Microsoft website, so I can now play a file successfully. Now I want to play another straight afterwards (like on an album). The problem is, the code I run to play the next song is triggered by a change of playstate (when media ends) and it doesn't work. I can step through and see that it's running properly and check that the MediaPlayer controls are being processed correctly; they just don't do anything. My code is as follows: Private Sub PlaySong() Dim FileName As String FileName = TrackDetails(CurrentTrack).Item("FileName") MediaPlayer1.Ctlcontrols.stop() MediaPlayer1.URL = FileName MediaPlayer1.Ctlcontrols.play() End Sub I'm running this when I click on a track and when a track finishes. It works for the MouseDown event but not for when the play state has changed. Any ideas welcome! Firebeard Quote
JumpyNET Posted July 18, 2005 Posted July 18, 2005 Hello again Right, I got details on how to set up the MediaPlayer control as part of a form from the Microsoft website, so I can now play a file successfully. Now I want to play another straight afterwards (like on an album). I managed to do it like this: Add a timer with interval of 10 and then add the code below. PlayNext() would be your function to play the next song. And Player would be the MediaPlayer10 object. Public EndOfStream As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load EndOfStream = True 'Start Timer Timer1.Enabled = True End Sub Private Sub Player_PlayStateChange(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles Player.PlayStateChange If e.newState = 8 Then EndOfStream = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'File EndOfStream If EndOfStream = True Then EndOfStream = False PlayNext() End If End Sub Quote
firebeard Posted August 30, 2005 Posted August 30, 2005 Thanks! Many thanks - I'll give that a go. Sorry it's been a while - I've had a nightmare project at work! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.