Record Class MediaSource

java.lang.Object
java.lang.Record
one.jpro.platform.media.MediaSource
Record Components:
source - string form of a media source URI
isLocal - true if this media source is local when running on a desktop/mobile or as a local resource to JPro server, otherwise false when inside the client's browser
jsFile - the non-local media source located inside the client's browser

public record MediaSource(String source, boolean isLocal, com.jpro.webapi.WebAPI.JSFile jsFile) extends Record
The MediaSource class represents a media resource. It is instantiated from the string form of a source URI or WebAPI.JSFile depending on whenever the resource is available locally, on the JPro server or in the browser's client.

The same MediaSource object may be shared among multiple MediaPlayer or MediaRecorder objects.

Author:
Besmir Beqiri
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    MediaSource(com.jpro.webapi.WebAPI.JSFile jsFile)
    Construct a media source for the given WebAPI.JSFile object.
    Construct a media source for the given File object.
    Construct a media source for the given URI string.
    MediaSource(String source, boolean isLocal, com.jpro.webapi.WebAPI.JSFile jsFile)
    Compact constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the local file representing this media source.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the isLocal record component.
    com.jpro.webapi.WebAPI.JSFile
    Returns the value of the jsFile record component.
    Returns the value of the source record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MediaSource

      public MediaSource(String source, boolean isLocal, com.jpro.webapi.WebAPI.JSFile jsFile)
      Compact constructor.
      Throws:
      NullPointerException - if the source is null.
      IllegalArgumentException - if the source is not a valid URI.
    • MediaSource

      public MediaSource(String source)
      Construct a media source for the given URI string.
      Parameters:
      source - a URI string
    • MediaSource

      public MediaSource(com.jpro.webapi.WebAPI.JSFile jsFile)
      Construct a media source for the given WebAPI.JSFile object.
      Parameters:
      jsFile - a JS file retrieved from the client's browser.
    • MediaSource

      public MediaSource(File file)
      Construct a media source for the given File object.
      Parameters:
      file - a local file
  • Method Details

    • file

      public Optional<File> file()
      Returns the local file representing this media source.
      Returns:
      an optional file object.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • source

      public String source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • isLocal

      public boolean isLocal()
      Returns the value of the isLocal record component.
      Returns:
      the value of the isLocal record component
    • jsFile

      public com.jpro.webapi.WebAPI.JSFile jsFile()
      Returns the value of the jsFile record component.
      Returns:
      the value of the jsFile record component