End of Song Event?
End of Song Event?
End of Song Event?
End of Song Event?
End of Song Event?
End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event?
End of Song Event? End of Song Event?
End of Song Event?
Go Back  Xtreme Visual Basic Talk > > > > End of Song Event?


Reply
 
Thread Tools Display Modes
  #1  
Old 11-02-2004, 11:38 PM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default End of Song Event?


I'm using Direct X to play sound files (mp3) and everything is fine. I'm using for example:

Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.AudioVideoPlayback

Private SoundPlayer As Audio
Everythings ok except I don't know what event, if any, is fired when the song finishes. I play using: SoundPlayer = New Audio(FileName, True) and I could set up a loop straight after till the sound finishes but that's not really what I want to do.

I prefer, like in mediaplayer, to have a certain event fired when the sound/sound file is finished.

Thanks
Reply With Quote
  #2  
Old 11-03-2004, 07:58 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Microsoft.DirectX.AudioVideoPlayback.Audio object raise a Stopping event when they reach the end of the file.
So, you may be able to do:
Private WithEvents Boombox As Audio
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 11-03-2004, 11:04 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Quote:
Originally Posted by Iceplug
Microsoft.DirectX.AudioVideoPlayback.Audio object raise a Stopping event when they reach the end of the file.
So, you may be able to do:
Private WithEvents Boombox As Audio
Hmm, don't quite get what you mean, can't seem to fathom it out......
Reply With Quote
  #4  
Old 11-03-2004, 08:20 PM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

If you declare your Audio class WithEvents, then you should be able to select the Audio class you are using from the left combobox at the top of the code window, and then select the Stopping event from the right menu.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 11-03-2004, 09:12 PM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Quote:
Originally Posted by Iceplug
If you declare your Audio class WithEvents, then you should be able to select the Audio class you are using from the left combobox at the top of the code window, and then select the Stopping event from the right menu.
I don't know what to say mate, that's cool and thank you very much. I had: Private SoundPlayer As Audio and using your suggestion changed it to Private WithEvents SoundPlayer As Audio and that instantly opened up 5 events that I was after, excellent. I've been programming for quite a while but usually just 'code' stuff, forms and modules, actually using class forms in their own right e.t.c. can be quite cool, cheers.
Reply With Quote
  #6  
Old 11-03-2004, 10:21 PM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

I'm trying all different things here and just getting in a muddle.

I'm getting the correct events e.t.c in my class form but need it in my real form (Form1) so can I have the events fired straight back to my Form1? Not sure, tried refiring an event from class to form1 with raiseevent but can't seem to get anything to work.
Reply With Quote
  #7  
Old 11-04-2004, 07:57 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

The form does not raise these events. If you declare the Audio class in your 'real form', then you'll receive the events from the audio class and that's what you select from the comboboxes in the top of your code window. If your class will receive the events and that's what you declare on the form, then your class will raise the event and that's what you should be searching for in the code window. Don't forget to declare the class WithEvents.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #8  
Old 11-04-2004, 01:51 PM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.AudioVideoPlayback

Public Class DXSoundPlayer

Public WithEvents SoundPlayer As Audio

  Public Sub PlaySound(ByVal FileName As String)
    SoundPlayer = New Audio(FileName, True)
  End Sub

  Public Sub StopSound()
    If Not SoundPlayer Is Nothing Then SoundPlayer.Stop()
  End Sub

  Private Sub SoundPlayer_Ending(ByVal sender As Object, ByVal e As System.EventArgs) Handles SoundPlayer.Ending
'This Fires When Song Ends..... (cool)
  End Sub

End Class
All works fine. All I want to do now is this. The 'SoundPlayer_Ending' routine is in my class, when the sound ends I need to be in my Form1 as I need it to do stuff there, I can't seem to access this event it from Form1, how can I have it (SoundPlayer_Ending) in Form1, or get to re-fire another event in Form1?

From 'Form1' I use 'Private DX As New DXSoundPlayer' then DX.'whatever', was trying the same with the above event but getting nowhere, bloody thing is driving me mad...... ;-)
Reply With Quote
  #9  
Old 11-04-2004, 09:00 PM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

You'll have to raise an event yourself for that.

Public Event SoundEnd As EventHandler

Then, when your class receives the Ending event from the Audio class, you raise the event.
RaiseEvent SoundEnd(Me, New EventArgs)

Your class will have to be declared WithEvents for you to find the SoundEnd event with your class in the top right combobox.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #10  
Old 11-05-2004, 06:46 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Quote:
Originally Posted by Iceplug
You'll have to raise an event yourself for that.

Public Event SoundEnd As EventHandler

Then, when your class receives the Ending event from the Audio class, you raise the event.
RaiseEvent SoundEnd(Me, New EventArgs)

Your class will have to be declared WithEvents for you to find the SoundEnd event with your class in the top right combobox.
OK the first lines seem ok, it's your last line that throws me..... How do I declare my class 'WithEvents'? If I add a 'WithEvents' to: Public Class DXSoundPlayer and make it: Public Class WithEvents DXSoundPlayer it shows a syntax error, also tried Public WithEvents Class DXSoundPlayer. Don't seem to get anything from my main form, grrrrr, bloody classes.
Reply With Quote
  #11  
Old 11-05-2004, 08:01 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Public Class DXSoundPlayer
is not the class declaration. It is the class itself.

A class declaration is where you are using:
Private Something As DXSoundPlayer
This is what you declare WithEvents:
Private WithEvents Something As DXSoundPlayer
This declaration should already be in the form.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #12  
Old 11-05-2004, 08:10 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Thanks for replying still, bet ya getting sick of me......

Yes, I have Private DX As New DXSoundPlayer already in Form1 but as soon as I add the withevents statement it give me a syntax error, same if I remove the 'new'.
Reply With Quote
  #13  
Old 11-05-2004, 08:19 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

A Syntax error? How did you type the line?
This works for me.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #14  
Old 11-05-2004, 08:33 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

My class is posted above. My Form1 is like this:

Code:
Public Class Form1
    Inherits System.Windows.Forms.Form

  Private DX As New DXSoundPlayer

'Windows Form Designer generated code'

  Private Sub Play()
    DX.PlaySound("C:\test.mp3")
  End Sub

End Class
It's on this form I need to raise an event.
As you can see I have the Private DX As New DXSoundPlayer, it wont let me add a 'WithEvents' to it......
Reply With Quote
  #15  
Old 11-05-2004, 08:53 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

What error do you get when you type the line?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #16  
Old 11-05-2004, 09:07 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

When I change the:
Code:
Private DX As New DXSoundPlayer
to
Code:
Private WithEvents DX As New DXSoundPlayer
it places a blue squiggle under DX, trying to run it tells me 'WithEvents does not raise any events'
Reply With Quote
  #17  
Old 11-05-2004, 09:09 AM
Iceplug's Avatar
IceplugEnd of Song Event? Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Did you declare the Public Event in the DXSoundPlayer class?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #18  
Old 11-05-2004, 09:30 AM
JustAdotNETUser JustAdotNETUser is offline
Freshman
 
Join Date: Oct 2004
Posts: 42
Default

Hooooooooooooooooooorayyyyyyyyyyyyyyyyyyy!!!!!!!!!!!!

lol

Well I done something like that earlier, didn't seem to do it, obviously I did something wrong.

It now works, cool, and cheers for sticking with me mate.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
End of Song Event?
End of Song Event?
End of Song Event? End of Song Event?
End of Song Event?
End of Song Event?
End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event? End of Song Event?
End of Song Event?
End of Song Event?
 
End of Song Event?
End of Song Event?
 
-->