Module: MMPlayer::Instructions::Player

Included in:
Context
Defined in:
lib/mmplayer/instructions/player.rb

Overview

Instructions dealing with the MPlayer

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

Add all of the MPlayer::Slave methods to the context as instructions



34
35
36
37
38
39
40
# File 'lib/mmplayer/instructions/player.rb', line 34

def method_missing(method, *args, &block)
  if @player.mplayer_respond_to?(method)
    @player.mplayer_send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#on_end_of_file(&callback) ⇒ Hash Also known as: end_of_file, eof

Assign a callback for when a file finishes playback

Parameters:

  • callback (Proc)

    The callback to execute when a file finishes playback

Returns:

  • (Hash)


19
20
21
# File 'lib/mmplayer/instructions/player.rb', line 19

def on_end_of_file(&callback)
  @player.add_end_of_file_callback(&callback)
end

#on_progress(&callback) ⇒ Hash Also known as: progress

Assign a callback for updating progress

Parameters:

  • callback (Proc)

    The callback to execute when progress is updated

Returns:

  • (Hash)


11
12
13
# File 'lib/mmplayer/instructions/player.rb', line 11

def on_progress(&callback)
  @player.add_progress_callback(&callback)
end