Class: ActiveVlc::LibVlc::Instance

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [""]) ⇒ Instance

Returns a new instance of Instance.



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

def initialize(args = [""])
  argc = args.length
  @argv = args.map{ |a| FFI::MemoryPointer.from_string a}
  test = FFI::MemoryPointer.new(:pointer, argc)
  test.put_array_of_pointer(0, @argv)

  @ptr = InstancePtr.new Api.libvlc_new(argc, test)
  raise "Unable to create a libvlc_instance_t" if @ptr.null?
end

Instance Attribute Details

#exit_callbackObject (readonly)

Returns the value of attribute exit_callback.



14
15
16
# File 'lib/activevlc/libvlc/instance.rb', line 14

def exit_callback
  @exit_callback
end

#ptrObject (readonly)

Returns the value of attribute ptr.



14
15
16
# File 'lib/activevlc/libvlc/instance.rb', line 14

def ptr
  @ptr
end

Instance Method Details

#add_interface(name = nil) ⇒ Object



66
67
68
# File 'lib/activevlc/libvlc/instance.rb', line 66

def add_interface(name = nil)
  Api.libvlc_add_intf(@ptr, name)
end

#at_exit(&block) ⇒ Object



60
61
62
63
64
# File 'lib/activevlc/libvlc/instance.rb', line 60

def at_exit(&block)
  Api.libvlc_set_exit_handler(@ptr, nil, nil)
  @exit_callback = block
  Api.libvlc_set_exit_handler(@ptr, @exit_callback, nil)
end

#create_list_player(list = nil, player = nil) ⇒ Object



42
43
44
45
46
# File 'lib/activevlc/libvlc/instance.rb', line 42

def create_list_player(list = nil, player = nil)
  mlp = Api.libvlc_media_list_player_new(@ptr)
  raise "Unable to create a libvlc_media_list_player_t" if mlp.null?
  MediaListPlayer.new(mlp, list, player)
end

#create_media(mrl) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/activevlc/libvlc/instance.rb', line 26

def create_media(mrl)
  if mrl =~ /\A[a-z]+:\/\/.+/
    m = Api.libvlc_media_new_location(@ptr, mrl)
  else
    m = Api.libvlc_media_new_path(@ptr, mrl)
  end
  raise "Unable to create a libvlc_media_t" if m.null?
  Media.new(m, mrl)
end

#create_media_listObject



36
37
38
39
40
# File 'lib/activevlc/libvlc/instance.rb', line 36

def create_media_list
  ml = Api.libvlc_media_list_new(@ptr)
  raise "Unable to create a libvlc_media_list_t" if ml.null?
  MediaList.new(ml)
end

#create_player(media = nil) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/activevlc/libvlc/instance.rb', line 48

def create_player(media = nil)
  if media and media.is_a?(Media)
    MediaPlayer.new(media)
  else
    MediaPlayer.new self
  end
end

#wait!Object



56
57
58
# File 'lib/activevlc/libvlc/instance.rb', line 56

def wait!
  Api.libvlc_wait(@ptr)
end