Skip to content

API Cheat Sheet [media5]

bapquad edited this page Feb 23, 2022 · 3 revisions

Working with camera and microphone. Playing the streaming as well.

Functions

StartCamera

Starts the camera if it has supported by user device.

Parameters

  • video:DOM - The DOM element of video tag. Required
  • width:number - The width of video object. Required
  • height:number - The height of video object. Required
  • callback:function - The callback called after enum devices. Optional

Return

Returns the Camera instance object.

Example

import {element5 as $, media5} from '@bapquad/element5'

let video = $.Create("video#camera");
let camera = media5.StartCamera(video, 320, 240, (devices) => {
  console.log(devices.length);
});

// Print the camera object
console.log(camera);

StartMicrophone

Starts the microphone if it has supported by user device.

Parameter

  • callback:function - The callback function called when init completely a session.

Return

Returns the PhoneACTX instance object.

Example

import {element5 as $, media5} from '@bapquad/element5'

let mic = media5.StartMicrophone();

// Print the microphone object
console.log(mic);

StartStream

Starts playing the live stream such that IP cameras.

Parameters

  • element:DOM - The element renders live stream. Required
  • url:string - The url of the live stream. Required
  • width:number - The width of the live stream. Required
  • height:number - The height of the live stream. Required

Return

Returns the assigned image element.

Example

import {element5 as $, media5} from '@bapquad/element5'

let image = $.create("img");

// Let view the IP Camera.
media5.StartStream(image, "http://154.453.125.14/mjpeg", 640, 480);

Class PhoneACTX

Manipulating the microphone audio context.

numberDevice

Retrieves the number of microphone devices.

Parameter

  • Has no parameter.

Return

Return the number of microphone devices.

Example

import {element5 as $, media5} from '@bapquad/element5'

microphone = media5.StartMicrophone((devices)=>{
  console.log(microphone.numberDevice());
}); 

stop.on("click", ()=>{
  microphone.stopSession();
});

next.on("click", ()=>{
  microphone.nextDevice();
});

stopSession

Stop the session of current microphone.

Parameter

  • Has no parameter.

Return

Returns the self PhoneACTX instance object.

Example

import {element5 as $, media5} from '@bapquad/element5'

microphone = media5.StartMicrophone((devices)=>{
  console.log(microphone.numberDevice());
}); 

stop.on("click", ()=>{
  microphone.stopSession();
});

next.on("click", ()=>{
  microphone.nextDevice();
});

nextDevice

Stop current session and initialize the next device in the list of microphone devices.

Parameter

  • callback:function - The function is called when created a session completely.

Return

Returns the self PhoneACTX instance object.

Example

import {element5 as $, media5} from '@bapquad/element5'

microphone = media5.StartMicrophone((devices)=>{
  console.log(microphone.numberDevice());
}); 

stop.on("click", ()=>{
  microphone.stopSession();
});

next.on("click", ()=>{
  microphone.nextDevice();
});

Class Camera

Manipulating the camera object.

nextCamera

Switch the next camera in the list of camera devices.

Parameter

  • Has no parameter.

Return

Returns the self Camera instance.

Example

import {element5 as $, media5} from '@bapquad/element5'

let video = $.Create("video#camera");
let camera = media5.StartCamera(video, 320, 240, (devices) => {
  console.log(devices.length);
});


$('button#next').on("click", () => {
  camera.nextCamera();
});