Differences with progress bar in win/mac os??

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Tomka
Posts: 59
Joined: Mon Apr 18, 2011 7:30 pm

Differences with progress bar in win/mac os??

Post by Tomka » Mon Aug 15, 2011 7:10 pm

Hi there,

i hope i´m able to explain my little problem...

I´m still developing a "little" project under win and mac os... it works fine under both os but not the progress bar which i use while playing wav-files.

Code: Select all

on mousedown
          if g_soundarray[g_sel_groupID_short]["antwort"]<>"" then                 //this checks if there is a wav existing
            set the filename of player "p1" to g_soundarray[g_sel_groupID_short]["antwort"]     //puts the path into the player
            put ((the duration of player "p1"/the timeScale of player "p1")*100) into SpieldauerInSekunden
            set the endValue of scrollbar "Zeit_bar1" to SpieldauerInSekunden
            put SpieldauerInSekunden div 6000 & ":"   into szeit                                            // calculating wav-length (mm:ss)
            if trunc((SpieldauerInSekunden/100) mod 60) < 10 then
               put szeit & "0" & trunc((SpieldauerInSekunden/100) mod 60) into szeit
            else
               put szeit & trunc((SpieldauerInSekunden/100) mod 60) into szeit
            end if
            put szeit into field "Feld_ZeitAbspielen1"                                                                                          //put the wav-Length (mm:ss) into the Textfield 
            set the layer of the group "Abspielmenü" to top
            put 0 into progress 
            set visible of group "Abspielmenü" to true //Abspielmenü sichtbar machen
            start player "p1"
            send "countUp" to me in 10 millisec
end mousedown

on countUp
   put progress+1 into progress
   set the thumbposition of scrollbar "Zeit_bar1" to progress
   if progress < SpieldauerInSekunden then send "countUp" to me in 10 millisec
   else
      set the thumbposition of scrollbar "Zeit_bar" to 0
      set the label of me to "Play"
      put "" into field "Feld_ZeitAbspielen1"
      set visible of group "Abspielmenü" to false                            //hide "Abspielmenü" (background+progress bar+field) 
   end if
end countUp
Under Win7 this code works fine. Under MacOs there´s a problem: The progress bar runs for a too long time. For example, the wav plays for 10 seconds and the progress bar runs for maybe 15-20secs (but only under mac os). The textfield contains the correct length of the wav-file.

Is there anything different using progress bars under mac than windows?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Differences with progress bar in win/mac os??

Post by bn » Mon Aug 15, 2011 9:00 pm

Hi Tomka,

I am afraid the Mac graphics are not fast enough. They can not keep up. 10 Milliseconds is a short interval, the difference between 10 and 40 is probably not visible.
I suggest that you don't rely on the 10 milliseconds as your measure of time. If you have a slow Windows computer you will see the same effect.
Here is an example that sets the scrollbar to percent and gauges the progress against the milliseconds. This way you are independent of the speed of the computer/graphics. It will just not be as smooth if it is too slow.

Code: Select all

local sStart, spielDauerInMilliseSekunden
on mouseUp
   set the startvalue of scrollbar 1 to 0
   set the endvalue of scrollbar 1 to 100
   put 9000 into spielDauerInMilliseSekunden -- = 9000 milliseconds
   set the thumbposition of scrollbar 1 to 0
   put the milliseconds into sStart
   send countUp to me in 50 milliseconds
end mouseUp

on countUp
   put (the milliseconds - sStart)/spielDauerInMilliseSekunden * 100 into progress
   set the thumbposition of scrollbar "Zeit_bar1" to progress
   if progress < 100 then send "countUp" to me in 40 millisec  -- change here
   else
      set the thumbposition of scrollbar "Zeit_bar1" to 0
      put the milliseconds - sStart & cr & progress into field 1
   end if
end countUp
Just make a new stack put this into a button, make a field, and a progressbar that you name "Zeit_bar1". Play with the send in xx milliseconds to see what is acceptable for you. The larger the interval the less you tax the computer.

Kind regards

Bernd

Tomka
Posts: 59
Joined: Mon Apr 18, 2011 7:30 pm

Re: Differences with progress bar in win/mac os??

Post by Tomka » Tue Aug 16, 2011 8:24 pm

Thanks alot Bernd! I´ll check this out.

I was also wondering why I choose 10ms... I´ll first check with "send 1 sec" ... maybe that will still solve the problem.

The funny thing is, that it runs under a bootcamp-win7 without any problems on the same mac :D ...

Post Reply