Sha256: f16f55e198dfe4a15485c44561e2d37316be4d2e085b2cc29b2fce15bd5ad6af

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

class PlayController < UIViewController
  attr_accessor :buttons

  def init
    super.tap do
      @buttons = []
    end
  end

  def viewDidLoad
    super

    self.view.addSubview(build_button("Modal", "tapped_modal"))
    self.view.addSubview(build_button("Frame", "tapped_frame"))
    self.view.backgroundColor = UIColor.whiteColor
  end

  def build_button(title, callback)
    button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
    button.setTitle(title, forState:UIControlStateNormal)
    button.sizeToFit

    rect = self.buttons.empty? ? CGRectMake(0, 0, 0, 0) : self.buttons.last.frame

    button.frame = [[rect.origin.x, rect.origin.y + rect.size.height + 10], button.frame.size]
    button.addTarget(self, action: callback, forControlEvents:UIControlEventTouchUpInside)

    self.buttons << button
    button
  end

  def local_file
    NSURL.fileURLWithPath(File.join(NSBundle.mainBundle.resourcePath, 'test.mp3'))
  end

  def tapped_modal
    BW::Media.play_modal(local_file)
  end

  def tapped_frame
    BW::Media.play(local_file) do |media_player|
      media_player.view.frame = [[10, 140], [self.view.frame.size.width - 20, 100]]
      self.view.addSubview media_player.view
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bubble-wrap-1.9.7 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.6 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.5 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.4 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.3 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.2 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.1 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.9.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.8.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.7.1 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.7.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.6.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.6.0.rc1 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.5.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.5.0.rc1 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.4.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.3.0 samples/media/app/controllers/play_controller.rb
bubble-wrap-1.3.0.osx samples/media/app/controllers/play_controller.rb