![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello again,
I've written a simple mp3 player but have a small glitch. I'm using a trackbar to show/control the position in the mp3 file. Once the file is playing a timer is set so that once a second I update the trackbar position. I would like however for the user to be able to change the position of the trackbar as well using sub trackbar_valuechanged. What happens however is that when the timer event is triggered the trackbar_valuechanged is subsequently triggered as well because the trackbar value is changed programatically. The sub trackbar_valuechanged then reassigns fmod.position which causes a small tick in the audio playback. Has anybody found the same problem? Thanks |
|
|||
|
OK!
Now to answer my own question... Using a global variable to keep track of the previous trackbar value I can reduce the effect. If the trackbar has changed significantly, the user moved the trackbar, only then do I change fmod.position. This works good enough. |
|
|||
|
kolbe,
one way of solving your problem would be to declare a global variable that your trackbar ValueChanged sub can use to differentiate a change made within the program from a change made by user input. In this example, the code in bar_ValueChanged only executes if the change DOES NOT come from Timer1_Tick: Sub Globals Dim auto_change End Sub Sub Timer1_Tick auto_change=true ' change bar.value here auto_change=false End Sub Sub bar_ValueChanged If auto_change=false Then ' change fmod.position here End If End Sub |
|
|||
|
I had the same problem and decided to show the advance of the song by a progress bar, and allow the user to select a new point in the song by moving the track bar - but the track bar is not moving, only by the user:
Sub Timer1_Tick ... progressBar1.Value = fmod.Position / fmod.Length1 * 100 ... end sub Sub Bar1_ValueChanged fmod.Position = bar1.Value * fmod.Length1 /100 End Sub not ellegant but efficient...
__________________
David Erez Ramat Hasharon, Israel |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to play 3gp file in Windows media player | vijay_vrc | Questions & Help Needed | 1 | 11-04-2008 12:55 AM |
| Mp3 Player | Thexmachine | Portuguese Forum | 2 | 08-20-2008 01:53 PM |
| player-recorder | derez | Share Your Creations | 0 | 03-13-2008 10:26 AM |
| Flash Player Control | alfcen | Basic4ppc Wishlist | 1 | 05-27-2007 12:51 PM |