media


CloudControl Pro 9 Docs / media

media

media module provides multimedia programming support. Currently only music playing and media file scanning are supported.

Table of contents

Classes

Functions

Functions

playMusic

playMusic(uri, volume?, looping?): Promise<MediaPlayer>

Play music. In 'async function' can be used keyword 'await' to wait for the music to be played.

Example

"nodejs";
const media = require("media");
const url = 'http://music.163.com/song/media/outer/url?id=1309394512.mp3';
playByUrl(url);
async function playByUrl(uri) {
  await media.playMusic(uri, 1.0, false);
}

Parameters

Name Type Description
uri string The music file path, or the URL.
volume? number The volume of the music, a float number between 0 and 1, default is 1.
looping? boolean Whether to loop the music, if looping is true, the music will be looped, default is false.

Returns

Promise<MediaPlayer>


scanFile

scanFile(file): void

Scan file. Used to add music files to the media library, and to add images to the system album.

See

https://developer.android.com/reference/android/media/MediaScannerConnection#scanFile(java.lang.String,%20java.lang.String)

Parameters

Name Type Description
file string The file path to be scanned.

Returns

void