Provides handling methods for package, media and compilation files, originating both from the local file system or an online resource.

Constructors

Properties

BytesPerMegaByte: number = ...
supportedMediaMimeTypes: string[] = ...

The set of supported media mime types

Remarks

Array of mime type strings

supportedMimeTypes: string[] = ...

The overall set of supported mime types

Remarks

This is a union of all specifically supported mime types

supportedPackageMimeTypes: string[] = ...

The set of supported package mime types

Remarks

Array of mime type strings

supportedPdfMimeTypes: string[] = ...

The set of supported PDF types

Remarks

Array of PDF type strings

supportedTextMimeTypes: string[] = ...

The set of supported text mime types

Remarks

Array of mime type strings

supportedXmlMimeTypes: string[] = ...

The set of supported XML mime types

Remarks

Array of mime type strings

Methods

  • Get the size in MB, rounded to one decimal place

    Parameters

    • sizeInBytes: null | number

    Returns null | number

  • Whether the given filename's extionsion matches any of the provided extensions

    Parameters

    • fileName: undefined | string

      the filename to test

    • extensions: string[]

      a set of extensions to compare against. Expected to be lower case.

    Returns boolean

    Remarks

    The lower case variant of the file extension is compared.

  • Reads the blob content as text.

    Parameters

    • content: Blob

    Returns Promise<String>

    Devdoc

    This does intentionally not use Blob.text() because there is no polyfill readily available in vite. At least some iPadOS devices do not have Blob.text() method implmented

  • A comparison function for ordered file extraction from a ZIP package/archive

    Parameters

    • zipEntryA: JSZipObject
    • zipEntryB: JSZipObject

    Returns number

    Remarks

    This is intended to produce the compilation first, then by guessed ascending file size

  • Tries to infer a correct file name from the URL, by splitting on the path, if possible.

    Parameters

    • url: URL

    Returns string

  • Tries to infer useful track metadata from the URL, by splitting the URL into parts, if possible.

    Parameters

    • url: URL

    Returns {
        album: string;
        artist: string;
        name: string;
    }

    • album: string
    • artist: string
    • name: string

    Remarks

    The artist is not guessed, it's always empty.

  • Tries to infer a useful track name from the file name.

    Parameters

    • fileName: string

    Returns string

    Remarks

    can be used to get a human readable name for a Track, which originates from a file name

  • Returns the last part, after the last slash

    Parameters

    • pathName: string

    Returns string

    Remarks

    For a complete typical path, this effectively returns the file name

  • Gets the file extension (part after the last dot) of a filename, in lower case

    Parameters

    • fileName: string

    Returns undefined | string

  • Gets a guessed MIME type from a filename, using an expected extension

    Parameters

    • fileName: string

    Returns null | string

    Remarks

    Applies some educated guess

  • Returns the response content as a promise that resolves with a file

    Parameters

    • response: Response

      the response to read the content from. The body and headers, especially the content length, are expected to be available

    • update: ((progress) => void)

      the callback function to use for periodic update. The progress is reported as percentage.

        • (progress): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<File>

    Remarks

    This works similar to the the Response.blob() function, but returns a file and additionally provides some progress information.

  • Maps a URL to a locally usable file name

    Parameters

    • url: URL

    Returns string

    Remarks

    can be used to match a track URL to a stored media file

    Devdoc

    Just removes the protocol

    Devdoc

    Full URL's (with protocol) are not usable for Replayer here as file names because they will be invalid as path insided a ZIP archive.

  • Gets the content MIME type from a fetch response

    Parameters

    • url: URL
    • response: Response

    Returns null | string

    Remarks

    Applies some educated guess in case the content type is not available from the response headers

  • Handles the given filename and blob as having media content and converts it into a MediaBlob

    Parameters

    • mediaFileName: string
    • content: Blob

    Returns MediaBlob

    Remarks

    Guesses the MIME type from the file name extension

    Devdoc

    This is used when a file is read from the ZIP package and not yet available as blob

  • Returns whether the given path/filename has no file extension

    Parameters

    • urlPath: string

    Returns boolean

  • Returns whether the given file name (by prefix/suffix) is a supported audio file name by Replayer

    Parameters

    • fileName: string

      the filename to test, which also can be a full URL

    Returns boolean

    Devdoc

    track types should later be determined by MIME type. For this, the MIME type should become part of the (readonly) track information, determined when the track URL is evaluated.

  • Returns whether the given file name (by it's extension) is a downloadable media file name by Replayer

    Parameters

    • fileName: undefined | string

    Returns boolean

    Remarks

    Downloadable are all online media files except YouTube URL's.

  • Returns whether the given file name represents a Mac OS X metadata file.

    Parameters

    • fileName: string

    Returns boolean

    Remarks

    Mac OS X metadata files are not processed by Replayer.

  • Returns whether the given path represents a Mac OS X resource fork.

    Parameters

    • path: string

    Returns boolean

    Remarks

    Mac OS X resource forks are not processed by Replayer.

  • Returns whether the given string is a path

    Parameters

    • input: string

    Returns boolean

    Remarks

    When ending with a slash, it's considered a path.

  • Returns whether the given file name (by prefix/suffix) is a supported PDF file name by Replayer

    Parameters

    • fileName: string

      the filename to test, which also can be a full URL

    Returns boolean

    Devdoc

    track types should later be determined by MIME type. For this, the MIME type should become part of the (readonly) track information, determined when the track URL is evaluated.

  • Returns whether the given MIME type is a supported PDF file MIME type by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

  • Returns whether the given file name (by prefix/suffix) is a processable file by Replayer

    Parameters

    • fileName: undefined | string

    Returns boolean

    Remarks

    Processable are all supported files of any type (compilations, media, including text)

  • Returns whether the given file name (by it's extension) is a supported compilation file name by Replayer

    Parameters

    • fileName: undefined | string

    Returns boolean

    Remarks

    XML (.xml) data is always considered a Compilation in this context

  • Returns whether the given MIME type is a supported compilation MIME type by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

    Remarks

    XML data is always considered a Compilation in this context

  • Returns whether this file is supported by Replayer, either by MIME type or the file name (by prefix/suffix)

    Parameters

    • file: File

    Returns boolean

  • Returns whether the given file name (by it's extension) is any of the supported types by Replayer

    Parameters

    • fileName: undefined | string

      the filename to test; for media files this also can be a full URL

    Returns boolean

  • Asserts whether the file represents a media file

    Parameters

    • file: File

    Returns boolean

    Remarks

    Currently, mp3, wav, flac, ogg, aiff, plus text are supported

  • Returns whether the given file name (by prefix/suffix) is a supported media file name by Replayer

    Parameters

    • fileName: undefined | string

      the filename to test, which also can be a full URL

    Returns boolean

    Remarks

    Currently, some audio, video, youtube plus txt, pdf, with name variations, are supported

  • Returns whether the given MIME type is a supported media MIME type by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

    Remarks

    Currently, MIME types for various audio, video, plus plain text and PDF, are supported.

  • Returns whether the given MIME type is any of the supported types by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

  • Asserts whether the file represents a package file

    Parameters

    • file: File

    Returns boolean

  • Returns whether the given file name (by it's extension) is a supported package file name by Replayer

    Parameters

    • fileName: undefined | string

    Returns boolean

  • Returns whether the given file name (by prefix/suffix) is a supported text file name by Replayer

    Parameters

    • fileName: string

      the filename to test, which also can be a full URL

    Returns boolean

    Devdoc

    track types should later be determined by MIME type. For this, the MIME type should become part of the (readonly) track information, determined when the track URL is evaluated.

  • Returns whether the given MIME type is a supported text file MIME type by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

  • Determines whether the string contains a valid URL, starting with the http|https protocol.

    Parameters

    • url: string

    Returns boolean

    true, when the URL is valid, false otherwise.

  • Returns whether the given file name (by prefix/suffix) is a supported video file name by Replayer

    Parameters

    • fileName: string

      the filename to test, which also can be a full URL

    Returns boolean

    Devdoc

    track types should later be determined by MIME type. For this, the MIME type should become part of the (readonly) track information, determined when the track URL is evaluated.

  • Asserts whether the file represents an XML compilation file

    Parameters

    • file: File

    Returns boolean

  • Asserts whether the file name represents an XML compilation file

    Parameters

    • fileName: string

    Returns boolean

    Remarks

    (rex is supported for historical reasons)

  • Returns whether the given MIME type is a supported XML compilation MIME type by Replayer

    Parameters

    • type: undefined | null | string

    Returns boolean

  • Returns whether the given URL is for a YouTube video

    Parameters

    • url: string

    Returns boolean