MMControl and progressbar

  • 15 years ago
    I have a program, for some reason when i set the value to progressbar 100 and the progressbar1.length * 100 with my mp3 player it will not progress through the timer set. here is the code... maybe i am doing something wrong.

    Code:

    Private Sub cmdClose_Click()
    mmcAudio.Command = "Close"
    End Sub
    Private Sub cmdPlay_Click()
    With cd1
       .Filter = "MP3 Files(*mp3)|*.mp3"
       .ShowOpen
       cmdPlay.Enabled = False
       mmcAudio.FileName = cd1.FileName
       mmcAudio.Command = "Open"
       mmcAudio.Command = "Play"
       mmcAudio.Wait = False
       Timer1.Enabled = True
    End With
    End Sub

    Private Sub cmdStop_Click()
    mmcAudio.Command = "Stop"
    End Sub

    Private Sub Form_Load()
       
       mmcAudio.Notify = False
       mmcAudio.Wait = True
       mmcAudio.Shareable = False
       mmcAudio.Command = "Close"
       'mmcAudio.DeviceType = "Other"
       mmcAudio.TimeFormat = mciFormatMsf
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    mmcAudio.Command = "Close"
    End Sub

    Private Sub mmcAudio_Done(NotifyCode As Integer)
       ProgressBar1.Value = 100
       Timer1.Enabled = False
       mmcAudio.Command = "Close"
       cmdPlay.Enabled = True
       
    End Sub


    Private Sub Timer1_Timer()
       ProgressBar1.Value = mmcAudio.Position / _
           mmcAudio.Length * 100
    End Sub


    I can play a Mp3 from this code, but i can't get the progressbar to work right.. thanks

    wildturkey
  • 15 years ago
    I'm no expert I'm sorry, the only thing that strikes me though is that you dont seem to be setting the ProgressBar.Max property at the outset.  All the times I've used a progr bar I've first set the max value and then updated it throughout the run,

    Bob
  • 15 years ago
    that helped a little, but still not seeing it to progress when playing an mp3, i have put it under the form_load and under the mmcaudio_done object


    i also set it to progressbar1.max = 1000
    and progressbar1.min = 0

    but somehow it is still not showing the progress...


    Thanks,
    William
  • 15 years ago
    NM LOL i fixed the problem... hahahah i  did't set the timer1 intervals. now do you know if its 1000 or 100?

    LOL /smack himself silly


    William
  • 15 years ago
    You beat me to it, I was just writing that as you posted!!

    1000 as far as I know
  • 15 years ago
    yea i am messing with it i set a lblStatus.caption = mmcAudio.Position & "/" & mmcAudio.Length too see if the counter and progress stops at the end at the same time, than adjust the timer as needed...


    Thanks for your Swiftness on helping me...

    William


  • 15 years ago

    Well i woke up and when i tested it with timer and count down the progressbar and lblcaption, does meet at the sametime so 1000 for interval does the job...

  • 15 years ago

    Hi:


    When you're waiting for an event in a loop you must use the instruction DoEvents inside the loop.


    Julio Cesar

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”