@yoda/multimedia. MediaPlayer

new MediaPlayer(streamopt)

The MediaPlayer includes support for playing variety of common media types, so that you can easily integrate audio into your applications.

var AudioManager = require('@yoda/audio').AudioManager;
var MediaPlayer = require('@yoda/multimedia').MediaPlayer;

var player = new MediaPlayer(AudioManager.STREAM_PLAYBACK);
player.start('/res/play.ogg');

The following are what we supported audio codec:

  • aac
  • aac_latm
  • ac3
  • adpcm_*
  • alac
  • amrnb
  • amrwb
  • ape
  • atrac3
  • flac
  • mp2
  • mp3*
  • mpc7
  • mpc8
  • opus
  • pcm_*
  • vorbis
  • wavpack
  • wmav1
  • wmav2
  • wmalossless
  • wmapro

And we supported multiple transfering protocols:

  • file
  • http/https
  • icecast
  • rtp
  • tcp
  • udp
  • tls_openssl
Parameters:
Name Type Attributes Default Description
stream number <optional>
STREAM_PLAYBACK

the stream type of the player.

Fires:

Members

status

Properties:
Name Type Description
indicates string

current state of the player

Methods

prepare(uri)

prepare with the given resource(URI).

Parameters:
Name Type Description
uri string

The resource uri to play.

Throws:

uri must be a valid string.

Type
Error

start(uri)

start asynchronously.

Parameters:
Name Type Description
uri string

The resource uri to play.

Throws:

uri must be a valid string.

Type
Error

stop()

This stops the MediaPlayer instance, .stop() will destroy the handle and emit 'cancel' event.

Don't use the instance anymore when you stopped it.

pause()

pause the playing media.

resume()

resume the paused media.

seek(pos, callback)

seek to pos.

Parameters:
Name Type Description
pos number

the position in ms.

callback function

get called when seek complete

getVolume()

get the volume