Class: Moc::Controller::Status::Live::Song

Inherits:
Object
  • Object
show all
Defined in:
lib/moc/controller/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ Song

Returns a new instance of Song.



18
19
20
# File 'lib/moc/controller/status.rb', line 18

def initialize (controller)
	@controller = controller
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



16
17
18
# File 'lib/moc/controller/status.rb', line 16

def controller
  @controller
end

Instance Method Details

#average_bitrateObject



37
38
39
40
# File 'lib/moc/controller/status.rb', line 37

def average_bitrate
	controller.send_command :get_avg_bitrate
	controller.get_integer.to_i
end

#bitrateObject



32
33
34
35
# File 'lib/moc/controller/status.rb', line 32

def bitrate
	controller.send_command :get_bitrate
	controller.get_integer.to_i
end

#channelsObject



22
23
24
25
# File 'lib/moc/controller/status.rb', line 22

def channels
	controller.send_command :get_channels
	controller.get_integer.to_i
end

#durationObject



75
76
77
# File 'lib/moc/controller/status.rb', line 75

def duration
	tags.time if tags
end

#fileObject



47
48
49
50
# File 'lib/moc/controller/status.rb', line 47

def file
	controller.send_command :get_sname
	controller.get_string.to_s
end

#inspectObject



79
80
81
# File 'lib/moc/controller/status.rb', line 79

def inspect
	"#<#{self.class.name}: track=#{track} title=#{title.inspect} artist=#{artist.inspect} album=#{album.inspect} channels=#{channels} bitrate=#{bitrate}(#{average_bitrate}) position=#{position}/#{duration || ??}>"
end

#positionObject



42
43
44
45
# File 'lib/moc/controller/status.rb', line 42

def position
	controller.send_command :get_ctime
	controller.get_integer.to_i
end

#rateObject



27
28
29
30
# File 'lib/moc/controller/status.rb', line 27

def rate
	controller.send_command :get_rate
	controller.get_integer.to_i
end

#tagsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/moc/controller/status.rb', line 52

def tags
	path = file

	if path.start_with?('http://') || path.start_with?('ftp://')
		controller.send_command :get_tags
		controller.get_tags
	else
		controller.send_command :get_file_tags
		controller.send_string  path
		controller.send_integer 0x01 | 0x02

		controller.wait_for(:file_tags).tags
	end
end