VideoView
API Reference: UI.VideoView
VideoView is a view to play video clips. Supported formats for both platforms are 3GPP (.3gp) and MPEG-4 (.mp4).
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 CodeAs 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 Basicsimport PageSampleDesign from "generated/pages/pageSample";
import { Route, Router } from "@smartface/router";
import { styleableComponentMixin } from '@smartface/styling-context';
import Application from "@smartface/native/application";
import VideoView from "@smartface/native/ui/videoview";
class StyleableVideoView extends styleableComponentMixin(VideoView) {}
//You should create new Page from UI-Editor and extend with it.
export default class Sample extends PageSampleDesign {
myVideoView: StyleableVideoView;
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();
const { headerBar } = this;
Application.statusBar.visible = false;
headerBar.visible = false;
}
onLoad() {
super.onLoad();
this.centerizeTheChildrenLayout();
this.myVideoView = new StyleableVideoView({
onReady: () => {
this.myVideoView.play();
},
});
this.myVideoView.ios.page = this;
this.myVideoView.loadURL("http-video-url");
this.addChild(this.myVideoView, "myVideoView", ".sf-videoView", {
margin: 20,
height: 250,
width: 250,
});
}
}
Usage
iOS provides controller bar for videos unlike Android.
You need to add some objects(like button or label) to get the same feature only for Android.
Video continues to play after the page is hidden
You should not forget to call the 'pause' or 'stop' method before the page is hidden.