Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to use a timer function to handle an event (starting and stoping music). I dunno how to use the timer well, I would appreciate some help on this (with some code included!).

 

I know that I have to set up a variable timer, and that its events will give me the 'flags' for starting or stoping the music, suppose that I already have the play and stop functions (in fact, I do!), how do I use timer to set use them?, I mean, after doing:

 

dim t1 as system.timers.timer = New system.timers.time ()

 

 

Which would be the rest of the code to make the music start to play on 30s after the time starts??

tHe pHrEaKy
Posted

are you using avxmediaplayer?

If so, you don't use timer, cause timer is a dangerous component to be used.

improper use of timer will cause your system with hidden bugs.

 

If u are using the mentioned component, try to use the events available in the component. like endstream and so on.

George C.K. Low

Posted
are you using avxmediaplayer?

If so, you don't use timer, cause timer is a dangerous component to be used.

improper use of timer will cause your system with hidden bugs.

 

If u are using the mentioned component, try to use the events available in the component. like endstream and so on.

 

No, I'm not, I'm using a csMusicLibrary that I found over the internet (its free), so, I don't think it would be a problem to use a timer. Still, I dunno how to use the timer :o

tHe pHrEaKy
Posted (edited)

I'm back :p

 

I already have that project mado for you... with the timer... working! :)

 

Still here I leave a small intro to timers.

'Declare a var of the type 'System.Windows.Forms.Timer' with events.
Dim WithEvents timer As New System.Windows.Forms.Timer

'Then before starting the timer set its properties
Me.timer.Interval = 10000     '10 sec interval between ticks

'Start the Timer
Me.timer.Start()

 

The timer have the most important event... Tick.

The code within this event is raised continuouslly in an interval of time equal to the specified in the Interval property.

In this example... every 10sec this event is raised.

   Private Sub timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer.Tick
         'Do whatever you want!
   End Sub

 

You can allays stop the timer using:

Me.timer.Stop()

 

And I think that's all folks... :D

 

Alex :p

Edited by AlexCode
Software bugs are impossible to detect by anybody except the end user.
Posted
Just perfect for me Alex!, it works like a charm, muito obrigado my friend, I owe you actions in the supermarket business we talked :)
tHe pHrEaKy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...