LiveMediaPlayer

API Reference: UI.LiveMediaPlayer

LiveMediaPlayer is a live streaming viewer based on NoMediaClient library. It is used for audio and video playback in RTMP/RTMPT/RTSP/HTTP/TCP/UDP/FILE format.

Original iOS library: https://github.com/NodeMedia/NodeMediaClient-iOS Original Android library: https://github.com/NodeMedia/NodeMediaClient-Android

LiveMediaPlayer Event Callback

You can listen the changes using onChange callback. Events are listed below.

LiveMediaPlayer Events

  • 1000: Connecting to video

  • 1001: Video connection successful

  • 1002: If the video connection fails, it will automatically reconnect.

  • 1003: The video starts to reconnect

  • 1004: End of the video playback

  • 1005: If the network is abnormal during video playback, it will automatically reconnect.

  • 1006: When the network connection times out, it will automatically reconnect.

  • 1100: The play buffer is empty.

  • 1101: The playback buffer is buffering data.

  • 1102: When the playback buffer reaches the bufferTime setting value, playback starts.

  • 1103: Received RTMP protocol stream EOF. It will automatically reconnect.

  • 1104: After decoding, the height and width of the video are obtained.

TypeScript
TypeScript
import Page = require("sf-core/ui/page");
import LiveMediaPlayer = require("sf-core/ui/livemediaplayer");
export default class Page1 extends Page {
router: any;
constructor () {
super();
this.onShow = onShow.bind(this);
this.onLoad = onLoad.bind(this);
}
}
/**
* @event onShow
* This event is called when a page appears on the screen (everytime).
* @param {function} superOnShow super onShow function
* @param {Object} parameters passed from Router.go function
*/
function onShow(superOnShow) {
this.myLiveMediaPlayer.start();
}
/**
* @event onLoad
* This event is called once when page is created.
* @param {function} superOnLoad super onLoad function
*/
function onLoad(superOnLoad) {
this.headerBar.visible = false;
this.myLiveMediaPlayer = new LiveMediaPlayer({
flexGrow: 1,
inputUrl: "https://tv-trt1.live.trt.com.tr/master_720.m3u8",
scaleType: LiveMediaPlayer.ScaleType.ASPECTFIT,
onChange: (params) => {
let {event, message} = params;
console.log("Event status code: " + event);
console.log("Message: " + message);
}
});
this.layout.addChild(this.myLiveMediaPlayer);
}