phreaky Posted April 18, 2004 Posted April 18, 2004 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?? Quote tHe pHrEaKy
georgepatotk Posted April 18, 2004 Posted April 18, 2004 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. Quote George C.K. Low
phreaky Posted April 18, 2004 Author Posted April 18, 2004 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 Quote tHe pHrEaKy
AlexCode Posted April 18, 2004 Posted April 18, 2004 (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 April 18, 2004 by AlexCode Quote Software bugs are impossible to detect by anybody except the end user.
phreaky Posted April 18, 2004 Author Posted April 18, 2004 Just perfect for me Alex!, it works like a charm, muito obrigado my friend, I owe you actions in the supermarket business we talked :) Quote tHe pHrEaKy
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.