Class: Airplay::Group

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/airplay/group.rb,
lib/airplay/group/players.rb

Defined Under Namespace

Classes: Players

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Group

Returns a new instance of Group.



11
12
13
14
15
# File 'lib/airplay/group.rb', line 11

def initialize(name)
  @devices = []
  @players = []
  @name = name
end

Instance Method Details

#<<(device) ⇒ Object

Public: Adds a device to the list

value - The Device

Returns nothing



23
24
25
# File 'lib/airplay/group.rb', line 23

def <<(device)
  @devices << device
end

#play(file_or_url, options = {}) ⇒ Object

Public: Plays a video on all the grouped devices

file_or_url - The file or url to be sent to the devices options - The options to be sent

Returns a Players instance that syncs the devices



34
35
36
37
# File 'lib/airplay/group.rb', line 34

def play(file_or_url, options = {})
  @players = @devices.map { |device| device.play(file_or_url, options) }
  Players.new(@players)
end

#view(media_or_io, options = {}) ⇒ Object

Public: Views an image on all the grouped devices

media_or_io - The file or url to be sent to the devices options - The options to be sent

Returns an array of arrays with the result of the playback



46
47
48
49
50
51
# File 'lib/airplay/group.rb', line 46

def view(media_or_io, options = {})
  @devices.map do |device|
    ok = device.view(media_or_io, options)
    [device, ok]
  end
end