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
2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 |
# File 'lib/ruby-macrodroid/actions.rb', line 2110 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
2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 |
# File 'lib/ruby-macrodroid/actions.rb', line 2143 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 |