Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @accurate-player/accurate-player-core

Index

Variables

Const SAFE_RAPID_PLAYBACK

SAFE_RAPID_PLAYBACK: 16 = 16

Functions

buildSeekStrategy

  • Helper for building seek strategy.

    Parameters

    • adapter: Adapter

      Adapter for issuing seek operations.

    • eventBus: EventMixin

      Event bus for listening to player events.

    • type: SeekStrategyType = ...

      Type of strategy to use. Defaults to QueuedSeek.

    Returns SeekStrategy

estimateDropFrame

  • estimateDropFrame(frameRate: number, dropRates?: number[]): boolean
  • Estimates whether the given frame rate should be considered as a drop frame frame rate.

    Parameters

    • frameRate: number

      The frame rate to test.

    • dropRates: number[] = ...

      Optional, a list of frame rates concidered to be drop frame.

    Returns boolean

estimateFrameRate

  • estimateFrameRate(frameRate: number, rates?: number[]): number
  • Estimates frame rate by finding the nearest matching value.

    Parameters

    • frameRate: number

      The frame rate to estimate.

    • rates: number[] = ...

      The rates to compare with.

    Returns number

Const frameRateToFraction

  • frameRateToFraction(quota: number): FrameRate
  • Converts a calculated frame rate to a FrameRate object (Numerator, denominator).

    Parameters

    • quota: number

      the calculated frame rate.

    Returns FrameRate

frameToSMPTE

  • frameToSMPTE(frameNumber: number, frameRate: number, dropFrame: boolean, offset?: number, baseFrameRate?: number): string
  • Converts from a frame number into a drop frame SMPTE time code.

    Parameters

    • frameNumber: number

      Frame number (integer).

    • frameRate: number

      Frame rate (double).

    • dropFrame: boolean

      Use drop frames in calculation? For manually toggling dropFrame support.

    • offset: number = 0

      This number of frames will be added to the resulting time code.

    • baseFrameRate: number = ...

      The base frame rate used to determine the number of digits for frame value.

    Returns string

    SMPTE time code.

framesInTimebase

  • framesInTimebase(frames1: number, numerator1: number, denominator1: number, numerator2: number, denominator2: number): number
  • Converts a frame in a timebase to the corresponding frame in another timebase.

    Parameters

    • frames1: number

      Frames to convert.

    • numerator1: number

      Source time base numerator.

    • denominator1: number

      Source time base denominator.

    • numerator2: number

      Target time base numerator.

    • denominator2: number

      Target time base denominator.

    Returns number

getConfiguredS3Instance

  • getConfiguredS3Instance(AWS: any, awsAccessKeyId: string, awsSecretAccessKey: string, region: string): any
  • Helper method. Creates an S3 instance with credentials and region set. AWS parameter need to be loaded separatly i.e import AWS from "aws-cli"

    Parameters

    • AWS: any

      aws-cli reference.

    • awsAccessKeyId: string

      access key id

    • awsSecretAccessKey: string

      secret key

    • region: string

      Region of the bucket. e.g "eu-west-1"

    Returns any

getMinBufferedFromTime

  • getMinBufferedFromTime(time: number, timeRanges: TimeRanges[]): BufferedTimespan | undefined
  • Gets the closest ending timespan relative to a specific time in a array of TimeRanges. Or undefined if any TimeRange is undefined, or if a TimeRange doesn't contain a matching timespan.

    Parameters

    • time: number

      The time to look for.

    • timeRanges: TimeRanges[]

      An array of TimeRanges.

    Returns BufferedTimespan | undefined

    The closest ending timespan, or undefined.

getPresignedUrl

  • getPresignedUrl(AWS: any, url: string, awsAccessKeyId: string, awsSecretAccessKey: string, region: string, expires?: number): string | undefined
  • Get a presigned url for s3. Handles s3 (start with s3://) and ordinary https urls. AWS parameter need to be loaded separatly i.e import AWS from "aws-cli"

    Parameters

    • AWS: any

      aws-cli reference.

    • url: string

      The url to sign

    • awsAccessKeyId: string

      access key id

    • awsSecretAccessKey: string

      secret key

    • region: string

      Region of the bucket. e.g "eu-west-1"

    • expires: number = 60

      expire duration

    Returns string | undefined

getTimespanFromTime

  • getTimespanFromTime(time: number, timeRanges: TimeRanges): BufferedTimespan | undefined
  • Gets the timespan that matches the given time, or undefined if no matching timespan is found.

    Parameters

    • time: number

      The time to look for.

    • timeRanges: TimeRanges

      The raw TimeRanges object from HTMLMediaElement.

    Returns BufferedTimespan | undefined

    The matching timespan, or undefined if no matching timespan is found.

isChrome

  • isChrome(): boolean
  • Checks if browser is Chrome

    Returns boolean

isFirefox

  • isFirefox(): boolean
  • Checks if browser is firefox.

    Returns boolean

Const isFrameRate

  • isFrameRate(object: any): object is FrameRate
  • Util guard to check if object can be assigned as frameRate.

    Parameters

    • object: any

      The object to be checked.

    Returns object is FrameRate

isLinux

  • isLinux(): boolean
  • Checks if browser platform is Linux.

    Returns boolean

Const isLoaded

  • isLoaded(element: HTMLMediaElement, requiredState?: MediaReadyState): boolean
  • Util that checks if a HTMLMediaElement is considered loaded.

    Parameters

    • element: HTMLMediaElement

      Element to check.

    • requiredState: MediaReadyState = ...

      Optional number deciding which readyState is required.

    Returns boolean

isMac

  • isMac(): boolean
  • Checks if browser platform is Mac

    Returns boolean

isSafari

  • isSafari(): boolean
  • Checks if browser is safari.

    Returns boolean

isTimeBuffered

  • isTimeBuffered(time: number, bufferedTimespan: BufferedTimespan, bufferMargin?: number): boolean
  • Checks if a specific time is considered to be buffered.

    Parameters

    • time: number

      The current time.

    • bufferedTimespan: BufferedTimespan

      The timespan to check against.

    • bufferMargin: number = 0

      Optional margin for buffer end.

    Returns boolean

    True if timespan contains time with the current margin.

isTrickMode

  • isTrickMode(rate: number): boolean
  • Checks if playback rate is out of native elements range.

    Parameters

    • rate: number

      The playbackrate.

    Returns boolean

    True if the playbackrate is out of range.

isWindows

  • isWindows(): boolean
  • Checks if browser platform is Windows

    Returns boolean

parseUrl

  • parseUrl(url: string): { bucket: string; item: string; region?: string } | undefined
  • Extracts information of an url before signing. Extracts bucket, region and item from https urls. Extracts bucket and item from s3 url.

    Parameters

    • url: string

      The url to analyze.

    Returns { bucket: string; item: string; region?: string } | undefined

platformContains

  • platformContains(pattern: string): boolean
  • Check if navigator platform contains a given pattern. Case insensitive.

    Parameters

    • pattern: string

      Patern to match.

    Returns boolean

secondsToFrames

  • secondsToFrames(time: number, frameRate: number): number
  • Converts the given time to an exact frame

    Parameters

    • time: number

      The time in seconds to convert

    • frameRate: number

      The frame rate of the media

    Returns number

secondsToTimecode

  • secondsToTimecode(time: number, frameRate: number, dropFrame: boolean, offset?: number, baseFrameRate?: number): string
  • Converts the given time to an SMPTE timecode

    Parameters

    • time: number

      The time in seconds to convert

    • frameRate: number

      The frame rate of the media

    • dropFrame: boolean

      Whether the returned timecode should be returned as a drop frame timecode.

    • Optional offset: number

      This number of frames will be added to the resulting time code.

    • Optional baseFrameRate: number

      The base frame rate used to determine the number of digits for frame value.

    Returns string

secondsToWallTime

  • secondsToWallTime(time: number): string
  • Converts a seconds time value to a wall time HH:MM:SS representation.

    Parameters

    • time: number

      Time in seconds to convert.

    Returns string

toFrames

  • toFrames(time: string | number, format: TimeFormat, frameRate: number, dropFrame: boolean, duration: number, offset?: number): number
  • Convert a certain SMPTE time code, standard time code, frame, second or millisecond to a frame value.

    Parameters

    • time: string | number

      Time value.

    • format: TimeFormat

      Format of time value.

    • frameRate: number

      Frame rate.

    • dropFrame: boolean

      Drop frame setting.

    • duration: number

      Duration of media object in seconds.

    • offset: number = 0

      The corresponding number of frames will be subtracted from the resulting value, iff input is SMPTE time code.

    Returns number

    Time in seconds.

toSeconds

  • toSeconds(time: string | number, format: TimeFormat, frameRate: number, dropFrame: boolean, duration: number, offset?: number): number
  • Convert a certain SMPTE time code, standard time code, frame, second or millisecond to an seconds value.

    Parameters

    • time: string | number

      Time value.

    • format: TimeFormat

      Format of time value.

    • frameRate: number

      Frame rate.

    • dropFrame: boolean

      Drop frame setting.

    • duration: number

      Duration of media object in seconds.

    • offset: number = 0

      The corresponding number of frames will be subtracted from the resulting value, iff input is SMPTE time code.

    Returns number

    Time in seconds.

toValidTimeValue

  • toValidTimeValue(input: string | number, format: TimeFormat): string | number | undefined
  • Tries to convert input to a valid time value.

    Parameters

    • input: string | number

      Input string or number.

    • format: TimeFormat

      Format of input string which is also used for the result.

    Returns string | number | undefined

    A valid time value or undefined if not able to produce it.

userAgentContains

  • userAgentContains(pattern: string): boolean
  • Check if user agent contains a given pattern. Case insensitive.

    Parameters

    • pattern: string

      Patern to match.

    Returns boolean

userInputToFrame

  • userInputToFrame(input: string, frameRate: number, duration: number, dropFrame: boolean, offset?: number, durationCap?: boolean): number | undefined
  • Converts user input to a frame, or undefined if it can't be parsed. Supports frame input, e.g. "123" -> 123 Supports 8 consecutive digits, e.g. 00000101 -> 00:00:01:01 -> 26 assuming frame rate is 25. Supports regular SMPTE timecodes, e.g. 00:00:00:01 -> 1. Returns undefined if input could not be converted to a frame.

    Parameters

    • input: string

      Input from user.

    • frameRate: number

      Frame rate to use.

    • duration: number

      Duration (in frames).

    • dropFrame: boolean

      Drop frame setting.

    • offset: number = 0

      The corresponding number of frames will be subtracted from the resulting value, iff input is SMPTE time code.

    • durationCap: boolean = true

      Ensures that the resulting frame never exceeds the duration.

    Returns number | undefined