Class: ControlMediaAction
- Inherits:
-
MediaAction
- Object
- MacroObject
- Action
- MediaAction
- ControlMediaAction
- Defined in:
- lib/ruby-macrodroid/actions.rb
Overview
note: to find a package id from an App name, try searching for the name on
the Google Play Store and the id will be returned in the URL once the
correct app has been clicked. e.g.
https://play.google.com/store/apps/details?id=com.google.android.music
Instance Attribute Summary
Attributes inherited from Action
Attributes inherited from MacroObject
Instance Method Summary collapse
-
#initialize(obj = nil) ⇒ ControlMediaAction
constructor
A new instance of ControlMediaAction.
- #to_s(colour: false, indent: 0) ⇒ Object (also: #to_summary)
Methods inherited from Action
Methods included from ObjectX
#action_to_object, #object_create, #varify
Methods inherited from MacroObject
Constructor Details
#initialize(obj = nil) ⇒ ControlMediaAction
Returns a new instance of ControlMediaAction.
2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 |
# File 'lib/ruby-macrodroid/actions.rb', line 2181 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro = obj s = e.text('item/description').to_s app = s[/Simulate Media Button \(([^\)]+)/,1] if app then { application_name: app, package_name: APPS[app], simulate_media_button: true } else {} end end = { application_name: "Google Play Music", option: "Play/Pause", package_name: "com.google.android.music", send_media_player_commands: false, simulate_media_button: true, } super(.merge h) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 |
# File 'lib/ruby-macrodroid/actions.rb', line 2214 def to_s(colour: false, indent: 0) @s = 'Media ' + @h[:option] #+ @h.inspect if @h[:simulate_media_button] then @s += "\nSimulate Media Button (%s)" % @h[:application_name] end super() end |