Class: Ray::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/ray/audio.rb

Overview

Represents an audio channel, where sounds are played.

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Channel

Creates a channel.

Parameters:

  • id (Integer)

    Identifer of the channel.



6
7
8
# File 'lib/ray/audio.rb', line 6

def initialize(id)
  @id = id
end

Instance Method Details

#pauseObject

Pauses the channel.



23
24
25
# File 'lib/ray/audio.rb', line 23

def pause
  Ray::Audio.pause(@id)
end

#paused?true, false

Returns True if the channel is paused.

Returns:

  • (true, false)

    True if the channel is paused.



33
34
35
# File 'lib/ray/audio.rb', line 33

def paused?
  Ray::Audio.paused?(@id)
end

#play(sound, times = 1) ⇒ Object

Plays a sound on the channel.

Parameters:

  • sound (Ray::Sound)

    The sound to be played

  • times (Integer, :forever) (defaults to: 1)

    How many times the sound should be played.



13
14
15
# File 'lib/ray/audio.rb', line 13

def play(sound, times = 1)
  sound.play(@id, times)
end

#playing?true, false

Returns True if a sound is being played.

Returns:

  • (true, false)

    True if a sound is being played.



38
39
40
# File 'lib/ray/audio.rb', line 38

def playing?
  Ray::Audio.playing?(@id)
end

#resumeObject

Resumes from pause.



28
29
30
# File 'lib/ray/audio.rb', line 28

def resume
  Ray::Audio.resume(@id)
end

#stopObject

Stops playing on the channel, without being able to resume.



18
19
20
# File 'lib/ray/audio.rb', line 18

def stop
  Ray::Audio.stop(@id)
end