Class: Plaything::OpenAL::Source
- Inherits:
-
TypeClass
- Object
- TypeClass
- Plaything::OpenAL::Source
- Defined in:
- lib/plaything/objects/source.rb
Instance Method Summary collapse
-
#buffers_processed ⇒ Integer
Number of processed buffers.
-
#buffers_queued ⇒ Integer
Number of queued buffers.
-
#detach_buffers ⇒ Object
Detach all queued or attached buffers.
-
#pause ⇒ Object
Pause playback.
-
#play ⇒ Object
Start playback.
-
#playing? ⇒ Boolean
True if source is in stopped state.
-
#sample_offset ⇒ Integer
How many samples (/ channels) that have been played from the queued buffers.
-
#should_be_playing? ⇒ Boolean
True if source should currently be playing audio.
-
#starved? ⇒ Boolean
True if audio should be playing (#play has been called, but not #stop or #pause), but isn’t playing.
-
#state ⇒ Symbol
:initial, :paused, :playing, :stopped.
-
#stop ⇒ Object
Stop playback and rewind the source.
-
#stopped? ⇒ Boolean
True if source is in stopped state.
Instance Method Details
#buffers_processed ⇒ Integer
returns #buffers_queued if source is not playing!
Returns number of processed buffers.
47 48 49 |
# File 'lib/plaything/objects/source.rb', line 47 def buffers_processed get(:buffers_processed, Integer) end |
#buffers_queued ⇒ Integer
Returns number of queued buffers.
41 42 43 |
# File 'lib/plaything/objects/source.rb', line 41 def buffers_queued get(:buffers_queued, Integer) end |
#detach_buffers ⇒ Object
all buffers must be processed for this operation to succeed.
all buffers are considered processed when #stopped?.
Detach all queued or attached buffers.
55 56 57 |
# File 'lib/plaything/objects/source.rb', line 55 def detach_buffers set(:buffer, 0) end |
#pause ⇒ Object
Pause playback.
13 14 15 16 |
# File 'lib/plaything/objects/source.rb', line 13 def pause @should_be_playing = false OpenAL.source_pause(self) end |
#play ⇒ Object
Start playback.
7 8 9 10 |
# File 'lib/plaything/objects/source.rb', line 7 def play @should_be_playing = true OpenAL.source_play(self) end |
#playing? ⇒ Boolean
Returns true if source is in stopped state.
70 71 72 |
# File 'lib/plaything/objects/source.rb', line 70 def state == :playing end |
#sample_offset ⇒ Integer
Returns how many samples (/ channels) that have been played from the queued buffers.
36 37 38 |
# File 'lib/plaything/objects/source.rb', line 36 def sample_offset get(:sample_offset, Integer) end |
#should_be_playing? ⇒ Boolean
Returns true if source should currently be playing audio.
31 32 33 |
# File 'lib/plaything/objects/source.rb', line 31 def @should_be_playing end |
#starved? ⇒ Boolean
Returns true if audio should be playing (#play has been called, but not #stop or #pause), but isn’t playing.
26 27 28 |
# File 'lib/plaything/objects/source.rb', line 26 def starved? and not end |
#state ⇒ Symbol
Returns :initial, :paused, :playing, :stopped.
60 61 62 |
# File 'lib/plaything/objects/source.rb', line 60 def state get(:source_state) end |
#stop ⇒ Object
Stop playback and rewind the source.
19 20 21 22 |
# File 'lib/plaything/objects/source.rb', line 19 def stop @should_be_playing = false OpenAL.source_stop(self) end |
#stopped? ⇒ Boolean
Returns true if source is in stopped state.
65 66 67 |
# File 'lib/plaything/objects/source.rb', line 65 def stopped? state == :stopped end |