README.md in bubble-wrap-1.1.2 vs README.md in bubble-wrap-1.1.3

- old
+ new

@@ -63,10 +63,16 @@ ```ruby require 'bubble-wrap/location' ``` +If you wish to only include the `Media` wrapper: + +```ruby +require 'bubble-wrap/media' +``` + If you want to include everything (ie kitchen sink mode) you can save time and do: ```ruby require 'bubble-wrap/all' ``` @@ -160,10 +166,11 @@ * `App.notification_center` * `App.user_cache` * `App.states` * `App.frame` * `App.delegate` +* `App.shared` * `App.current_locale` ### Device @@ -241,11 +248,11 @@ ```ruby def viewWillAppear(animated) @foreground_observer = App.notification_center.observe UIApplicationWillEnterForegroundNotification do |notification| loadAndRefresh end - + @reload_observer = App.notification_center.observe ReloadNotification do |notification| loadAndRefresh end end @@ -288,11 +295,11 @@ def viewDidLoad @label = UILabel.alloc.initWithFrame [[20,20],[280,44]] @label.text = "" view.addSubview @label - + observe(@label, :text) do |old_value, new_value| puts "Hello from viewDidLoad!" end end @@ -339,10 +346,26 @@ end ``` Also available is `BW::Location.get_significant`, for monitoring significant location changes. +## Media + +Added wrapper for playing remote and local media. Available are `modal` and custom presentation styles: + +```ruby +# Plays in your custom frame +local_file = NSURL.fileURLWithPath(File.join(NSBundle.mainBundle.resourcePath, 'test.mp3')) +BW::Media.play(local_file) do |media_player| + media_player.view.frame = [[10, 100], [100, 100]] + self.view.addSubview media_player.view +end + +# Plays in an independent modal controller +BW::Media.play_modal("http://www.hrupin.com/wp-content/uploads/mp3/testsong_20_sec.mp3") +``` + ## UI ### Gestures Extra methods on `UIView` for working with gesture recognizers. A gesture recognizer can be added using a normal Ruby block, like so: @@ -496,11 +519,11 @@ ## Reactor **Since: > version 1.0.0** `BubbleWrap::Reactor` is a simplified, mostly complete implementation of -the [Event Machine](http://rubyeventmachine.com/) API. In fact +the [Event Machine](http://rubyeventmachine.com/) API. In fact `BubbleWrap::Reactor` is aliased to `EM` in the runtime environment. ### Deferables BubbleWrap provides both a `Deferrable` mixin and a `DefaultDeferrable` @@ -586,15 +609,15 @@ Great scott! ``` ### Scheduling operations -You can use `EM.schedule` to schedule blocks to be executed +You can use `EM.schedule` to schedule blocks to be executed asynchronously. BubbleWrap deviates from the EventMachine API here in that it also provides `EM.schedule_on_main` which -makes sure that the task is run asynchronously, but on the -application's main thread - this is necessary if you are +makes sure that the task is run asynchronously, but on the +application's main thread - this is necessary if you are updating the user interface. ```ruby > EM.schedule { puts Thread.current.object_id } 146027920 @@ -605,18 +628,18 @@ ``` ### Deferrable operations You can also use `EM.defer` in much the same way as `EM.schedule` -with one important difference, you can pass in a second `proc` +with one important difference, you can pass in a second `proc` which will be called when the first has completed, and be passed it's result as an argument. Just like `EM.schedule`, `EM.defer` also has an `EM.defer_on_main` version. ```ruby -> operation = proc { 99 } +> operation = proc { 88 } => #<Proc:0x6d763c0> -> callback = proc { |speed| puts speed >= 99 ? "Time travel!" : "Conventional travel!" } +> callback = proc { |speed| puts speed >= 88 ? "Time travel!" : "Conventional travel!" } => #<Proc:0x8bd3910> > EM.defer(operation, callback) => nil Time travel! ```