Skip to main content
Version: 7.2.0

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.
note

The components in the example are added from the code for better showcase purposes. To learn more about the subject you can refer to:

Adding Component From Code

As a best practice, Smartface recommends using the WYSIWYG editor in order to add components and styles to your page or library. To learn how to use UI Editor better, please refer to this documentation

UI Editor Basics
import PageSampleDesign from "generated/pages/pageSample";
import { Route, Router } from "@smartface/router";
import { styleableComponentMixin } from '@smartface/styling-context';
import LiveMediaPlayer from "@smartface/native/ui/livemediaplayer";


class StyleableLiveMediaPlayer extends styleableComponentMixin(LiveMediaPlayer) {}

//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
myLiveMediaPlayer: StyleableLiveMediaPlayer;

constructor(private router?: Router, private route?: Route) {
super({});
}

// The page design has been made from the code for better
// showcase purposes. As a best practice, remove this and
// use WYSIWYG editor to style your pages.
centerizeTheChildrenLayout() {
this.dispatch({
type: "updateUserStyle",
userStyle: {
flexProps: {
flexDirection: 'ROW',
justifyContent: 'CENTER',
alignItems: 'CENTER'
}
}
})
}

onShow() {
super.onShow();
this.myLiveMediaPlayer.start();
}

onLoad() {
super.onLoad();
this.centerizeTheChildrenLayout();

this.myLiveMediaPlayer = new StyleableLiveMediaPlayer({
inputUrl: "https://multiplatform-f.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8",
scaleType: LiveMediaPlayer.ScaleType.ASPECTFIT,
onChange: (params) => {
let { event, message } = params;
console.log("Event status code: " + event);
console.log("Message: " + message);
},
});
this.addChild(this.myLiveMediaPlayer, "myLiveMediaPlayer", null, {
flexGrow: 1,
});
}
}