Options
All
  • Public
  • Public/Protected
  • All
Menu

Module media

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

Index

Classes

Functions

Functions

playMusic

  • playMusic(uri: string, volume?: number, looping?: boolean): 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

    • uri: string

      The music file path, or the URL.

    • Optional volume: number

      The volume of the music, a float number between 0 and 1, default is 1.

    • Optional 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: string): void