Class: ActiveVlc::LibVlc::MediaPlayer

Inherits:
Object
  • Object
show all
Defined in:
lib/activevlc/libvlc/media_player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vlc_or_media) ⇒ MediaPlayer

Returns a new instance of MediaPlayer.



15
16
17
18
19
20
21
22
23
# File 'lib/activevlc/libvlc/media_player.rb', line 15

def initialize(vlc_or_media)
  @media = nil
  if vlc_or_media.is_a?(Media)
    @media = vlc_or_media
    @ptr = Api.libvlc_media_player_new_from_media(vlc_or_media.ptr)
  else
    @ptr = Api.libvlc_media_player_new(vlc_or_media.ptr)
  end
end

Instance Attribute Details

#mediaObject

Returns the value of attribute media.



13
14
15
# File 'lib/activevlc/libvlc/media_player.rb', line 13

def media
  @media
end

#ptrObject (readonly)

Returns the value of attribute ptr.



13
14
15
# File 'lib/activevlc/libvlc/media_player.rb', line 13

def ptr
  @ptr
end

Instance Method Details

#event_managerObject



25
26
27
28
29
# File 'lib/activevlc/libvlc/media_player.rb', line 25

def event_manager
  event_manger = Api.libvlc_media_player_event_manager(@ptr)
  raise "Unable to get EventManager for MediaPlayer #{@ptr.inspect}" unless event_manger
  EventManager.new event_manger
end

#pauseObject



43
44
45
# File 'lib/activevlc/libvlc/media_player.rb', line 43

def pause
  if_media { Api.libvlc_media_player_pause @ptr}
end

#playObject



37
38
39
# File 'lib/activevlc/libvlc/media_player.rb', line 37

def play
  if_media { Api.libvlc_media_player_play @ptr }
end

#playing?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/activevlc/libvlc/media_player.rb', line 47

def playing?
  Api.libvlc_media_player_is_playing @ptr
end

#stateObject



51
52
53
# File 'lib/activevlc/libvlc/media_player.rb', line 51

def state
  Api.libvlc_media_player_get_state @ptr
end

#stopObject



40
41
42
# File 'lib/activevlc/libvlc/media_player.rb', line 40

def stop
  if_media { Api.libvlc_media_player_stop @ptr }
end