Skip to content

libvlc.Medium.Constructor

Andrew Lambert edited this page Nov 26, 2022 · 12 revisions

libvlc.Medium.Constructor

Method signatures

 Protected Sub Constructor(FileDescriptor As Integer)
 Sub Constructor(AddRef As libvlc.Medium)
 Protected Sub Constructor(FromPtr As Ptr, AddRef As Boolean)
 Sub Constructor(FromStream As Readable) ' unsafe; see below

Parameters

Protected Constructor(Integer)

Name Type Comment
FileDescriptor Integer A file descriptor from which to construct the medium.

Constructor(libvlc.Medium)

Name Type Comment
AddRef Medium An instance of Medium to duplicate.

Protected Constructor(Ptr, Boolean)

Name Type Comment
FromPtr Ptr A pointer to a libvlc_media_t structure.
AddRef Boolean If True, the structure's reference count is incremented.

Constructor(Readable)

Name Type Comment
FromStream Readable A Readable object from which media data will be read. (Unsafe; see below.)

Remarks

Creates a new Medium object from something other than a FolderItem or URL (use Operator_Convert for those.)

Using Constructor(Readable)

libvlc 3.0 added the ability for applications to load media directly from memory. The Readable parameter should refer to the object from which the raw media data will be read. Unfortunately, this feature cannot be used safely in a Xojo application because playback occurs on a separate preemptive thread. caveat implementor.

This allows Medium instances to be created from anything that is (or can be turned into) a Readable object:

Using a MemoryBlock

  Dim data As MemoryBlock = GetTheDataSomeHow()
  Dim bs As New BinaryStream(mb)
  Dim m As New libvlc.Medium(bs)

Using a FolderItem

  Dim bs As BinaryStream = BinaryStream.Open(GetOpenFolderItem(""))
  Dim m As New libvlc.Medium(bs)

Using the StandardInputStream

  Dim m As New libvlc.Medium(StdIn)

Note: Seeking within the media is only available when you pass a BinaryStream; other implementors of Readable will not be seekable.

Clone this wiki locally