Since

0.1

Android

Ios

Controls sound files.

Example

import Sound from '@smartface/native/device/sound';
var mySound = new Sound();
mySound.onReady = function() {
mySound.play();
};
mySound.isLooping = true;
mySound.loadURL(your-url);

Hierarchy

Methods

  • Creates an event emitter instance to listen for the actions

    Returns

    Call the function to remove the event

    Parameters

    Returns (() => void)

      • (): void
      • Creates an event emitter instance to listen for the actions

        Returns

        Call the function to remove the event

        Returns void

  • Creates an event emitter instance to listen for the actions

    Returns

    Call the function to remove the event

    Parameters

    Returns (() => void)

      • (): void
      • Creates an event emitter instance to listen for the actions

        Returns

        Call the function to remove the event

        Returns void

  • Removes the specified event and invokes the callback after it is removed

    Parameters

    Returns void

  • Triggers the event manually.

    Parameters

    • event: "ready" | "finish"
    • Rest ...args: any[]

      Arguments that needs to be passed down

    Returns void

  • Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    Parameters

    Returns void

  • Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

    Parameters

    Returns void

  • Pauses the sound.

    Method

    pause

    Android

    Ios

    Since

    0.1

    Returns void

  • Seeks to specified time position.

    Method

    seekTo

    Android

    Ios

    Since

    0.1

    Parameters

    • milliseconds: number

    Returns void

  • Stops the sound.

    Method

    stop

    Android

    Ios

    Since

    0.1

    Returns void

  • plays the sound.

    Method

    play

    Android

    Ios

    Since

    0.1

    Returns void

  • Loads the source. Permissions#storage permission is required to load local files.

    Method

    loadFile

    Android

    Ios

    Since

    0.1

    Parameters

    • file: FileImpl

    Returns void

  • Loads the source.

    Method

    loadURL

    Android

    Ios

    Since

    0.1

    Parameters

    • url: string

    Returns void

Properties

nativeObject: { [key: string]: any }

Type declaration

  • [key: string]: any
isPlaying: boolean

Checks whether the sound is playing.

Property

Android

Ios

Since

0.1

isLooping: boolean

Gets/sets whether the sound is looping or non-looping.

Property

Android

Ios

Since

0.1

volume: number

Gets/sets the volume of the sound. The range is between {0.0, 1.0}

Property

Android

Ios

Since

0.1

totalDuration: number

Gets the duration in milliseconds.

Property

Android

Ios

Since

0.1

currentDuration: number

Gets the current duration in milliseconds.

Property

Android

Ios

Since

0.1

pick: ((params: { page: IPage<"load" | "dismissComplete" | "dismissStart" | "dismissCancel" | "hide" | "show" | "orientationChange" | "safeAreaPaddingChange", MobileOSProps<PageIOSParams, PageAndroidParams>, any>; onSuccess: ((e: { sound: ISound }) => void); onFailure: (() => void) }) => void)

Type declaration

    • (params: { page: IPage<"load" | "dismissComplete" | "dismissStart" | "dismissCancel" | "hide" | "show" | "orientationChange" | "safeAreaPaddingChange", MobileOSProps<PageIOSParams, PageAndroidParams>, any>; onSuccess: ((e: { sound: ISound }) => void); onFailure: (() => void) }): void
    • Picks a sound on the device.

      Example

      import Sound from '@smartface/native/device/sound';
      Sound.android.pick({onSuccess: soundPicked});

      function soundPicked(e) {
      if(!e.sound.isPlaying)
      e.sound.play();
      }

      Method

      pick

      Static

      Android

      Since

      1.1.8

      Parameters

      • params: { page: IPage<"load" | "dismissComplete" | "dismissStart" | "dismissCancel" | "hide" | "show" | "orientationChange" | "safeAreaPaddingChange", MobileOSProps<PageIOSParams, PageAndroidParams>, any>; onSuccess: ((e: { sound: ISound }) => void); onFailure: (() => void) }

        Object describing function parameters.

        • page: IPage<"load" | "dismissComplete" | "dismissStart" | "dismissCancel" | "hide" | "show" | "orientationChange" | "safeAreaPaddingChange", MobileOSProps<PageIOSParams, PageAndroidParams>, any>

          (required since 1.1.8)

        • onSuccess: ((e: { sound: ISound }) => void)
            • (e: { sound: ISound }): void
            • Callback for success situation.

              Parameters

              Returns void

        • onFailure: (() => void)
            • (): void
            • Callback for failure situation.

              Returns void

      Returns void

Events

onReady: (() => void)

Type declaration

    • (): void
    • Triggered when the sound is ready for playing.

      Since

      0.1

      Android

      Ios

      Deprecated

      onReady

      Example

      import Sound from '@smartface/native/device/sound';

      const sound1 = new Sound();
      sound.on(Sound.Events.Ready, (params) => {
      console.info('onReady', params);
      });

      Returns void

onFinish: (() => void)

Type declaration

    • (): void
    • Triggered when the sound complited playing.

      onFinish

      Android

      Ios

      Deprecated

      Since

      0.1

      Example

      import Sound from '@smartface/native/device/sound';

      const sound1 = new Sound();
      sound1.on(Sound.Events.Finish, (params) => {
      console.info('onFinish', params);
      });

      Returns void

Generated using TypeDoc