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.
2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 |
# File 'lib/ruby-macrodroid/actions.rb', line 2210 def initialize(obj=nil) h = if obj.is_a? Hash then obj elsif obj.is_a? Array e, macro, h2 = 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 }.merge h2 else { send_media_player_commands: true, simulate_media_button: false } end end #puts 'h: ' + h.inspect = { option: "Play/Pause", send_media_player_commands: true, simulate_media_button: false, } super(.merge h) end |
Instance Method Details
#to_s(colour: false, indent: 0) ⇒ Object Also known as: to_summary
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 |
# File 'lib/ruby-macrodroid/actions.rb', line 2246 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] else @s += "\nSimulate Audio Button" end super() end |