Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set audio source to itunes on startup.

  • Loading branch information...
commit 25fa5453953ded6e37b520d9302346a231c94780 1 parent 6fa3864
@joeyw joeyw authored
Showing with 32 additions and 0 deletions.
  1. +2 −0  app/app.rb
  2. +22 −0 app/models/airfoil.rb
  3. +8 −0 test/airfoil_test.rb
View
2  app/app.rb
@@ -31,6 +31,8 @@ class App < Sinatra::Base
Pusher.key = Play.config.pusher_key
Pusher.secret = Play.config.pusher_secret
+ Airfoil.audio_source = "iTunes" if Airfoil.installed?
+
set :public_folder, "#{dir}/frontend/public"
set :static, true
set :mustache, {
View
22 app/models/airfoil.rb
@@ -27,6 +27,28 @@ def self.get_speakers
}
end
+ # Get the current Airfoil audio source name.
+ #
+ # Returns String Airfoil audio source name.
+ def self.audio_source
+ app.current_audio_source.name.get
+ end
+
+ # Set audio source for Airfoil.
+ #
+ # setting - String application name.
+ #
+ # Returns String audio source name.
+ def self.audio_source=(setting)
+ app.application_sources.id_.get.each do |id|
+ name = app.application_sources.ID(id).name.get
+ if name.eql?(setting)
+ app.current_audio_source.set(app.application_sources.get[id])
+ end
+ end
+ audio_source
+ end
+
# Get volume for all speakers.
#
# Returns Array of Floats speaker volumefrom 0.0 to 1.0.
View
8 test/airfoil_test.rb
@@ -39,4 +39,12 @@
end
end
+ test "audio source name get and set" do
+ Airfoil.audio_source = "QuickTime Player"
+ assert_equal "QuickTime Player", Airfoil.audio_source
+
+ Airfoil.audio_source = "iTunes"
+ assert_equal "iTunes", Airfoil.audio_source
+ end
+
end if Airfoil.installed? and ENV['CI'] != '1'
Please sign in to comment.
Something went wrong with that request. Please try again.