ashbb / green_shoes

Green Shoes is one of the colorful Shoes written in pure Ruby.
Other
204 stars 37 forks source link

button does not work in conjunction with animate? #75

Open nanenj opened 11 years ago

nanenj commented 11 years ago

Fiddling around with an MP3 player. The following code the link and the image 'button' works where as the -actual- button does not. Also the value for a video object's length does not appear to be calculated until the video is being played. (Or at least that's the case when playing .ogg files).

Removing the animate block entirely, the button actually works

require 'green_shoes'

Shoes.app( :width => 320, :height => 240, :title => "Ogg Player Demo" ) do
  space = " " * 3
  @song = video "c:/Repos/Ruby/mp3Player/song2.ogg"

  @link_Play = para space, link("Play") { @song.play },
        space, link("Pause") { @song.pause },
        space, link("Stop") { 
          @song.stop
          @song = video ''
        }

  @lbl_songLength = para('')

  @btn_Play = button "Play"
  @btn_Play.click { 
    @song.play
    @songLength = @song.length.to_i/1000
  }

  @img_Play = image "c:/Repos/Ruby/mp3Player/play_18x24.png"
  @img_Play.click { @song.play }
  animate do
    @songLength = @song.length.to_i/1000
    if @songLength != 0
      @lbl_songLength.replace("#{@songLength}")
    else
      @lbl_songLength.replace('')
    end
  end
end
ashbb commented 11 years ago

@nanenj Thanks for the post. Yes, this is a problem. But sorry, I have no solution for now. A workaround is to slow the rate of animate, e.g. animate(1). Not a good workaround though... xx-P

nnadboralski-zz commented 11 years ago

Okay, thanks for the confirmation at least, I still thought I was going crazy even after testing many, many different scenarios.