Page tree
Skip to end of metadata
Go to start of metadata

This guide explains how to use audio and video files in a project.

Using Audio Files

The Smartface let's you to play audio files in your application. There are 3 methods for audio files which are;

NAMEDESCRIPTION
playSoundPlays the specified sound media.
setSoundLevelSets sound level of the device. This action is used for setting the device sound levels.
 stopSoundStops all the playing sound media in the application.

Here is a sample code for using Audio features of the Smartface as below ;

var soundLevel = 5;
var btnPlaySound = new SMF.UI.TextButton({
        top : '10%',
        onPressed : function (e) {
            SMF.Multimedia.playSound("sample.mdi",
                true, false,
                function () {
                alert("started to play...");
            },
                function () {
                alert("finished...");
            });
        }
    });
page1.add(btnPlaySound);
var btnStopSound = new SMF.UI.TextButton({
        top : '25%',
        onPressed : function (e) {
            SMF.Multimedia.stopSound();
        }
    });
page1.add(btnStopSound);
var btnVolumeUp = new SMF.UI.TextButton({
        top : '40%',
        onPressed : function (e) {
            soundLevel++;
            SMF.Multimedia.setSoundLevel(soundLevel);
        }
    });
page1.add(btnVolumeUp);
var btnVolumeDown = new SMF.UI.TextButton({
        top : '55%',
        onPressed : function (e) {
            soundLevel--;
            SMF.Multimedia.setSoundLevel(soundLevel);
        }
    });
page1.add(btnVolumeDown);

Using Video Files

A Video object is a video display control object which uses native video player. It can display both in embedded style and full screen style.

var video1 = new SMF.UI.Video({
		left : "10%",
		top : "10%",
		width : "80%",
		height : "40%",
		controlStyle : SMF.UI.VideoControlStyle.EMBEDDED,
		contentUrl : "sample.m4v"
	});
page1.add(video1);
var btnPlay = new SMF.UI.TextButton({
		left : '10%',
		top : '52%',
		width : "80%",
		height : "10%",
		text : "Play Video",
		onPressed : function (e) {
			video1.playVideo();
		}
	});
page1.add(btnPlay);
var btnPause = new SMF.UI.TextButton({
		left : '10%',
		top : '64%',
		width : "80%",
		height : "10%",
		text : "Pause Video",
		onPressed : function (e) {
			video1.pauseVideo();
		}
	});
page1.add(btnPause);
var btnStop = new SMF.UI.TextButton({
		left : '10%',
		top : '76%',
		width : "80%",
		height : "10%",
		text : "Stop Video",
		onPressed : function (e) {
			video1.stopVideo();
		}
	});
page1.add(btnStop);

      

The Video object has some methods and properties to give more controls for users.

Methods

NAMEDESCRIPTION
animate
Changes property of the UI object with animation
captureThumbnail
Capture Thumbnail gets images from the running video objects according to time that you entered.
focus
Sets the active focus to a specified focusable object.
pauseVideo
Pauses the selected video. This actions pauses a video sequence. The video sequence is continued from its last position when re-activated with “Play Video” action.
playVideo
Plays the specified video media. This action plays a video file when executed. The video media can be in type of .3GP or Real Media streaming.
reset
It allows user to reset the specified object.
stopVideo
Stops the specified video media. This action stops the specified video and video playing position is rolled back to the start position.

Here is an example code which uses playVideo() method of the Video object:

var video1 = new SMF.UI.Video({
		left : "10%",
		top : "10%",
		width : "80%",
		height : "40%",
		controlStyle : SMF.UI.VideoControlStyle.EMBEDDED,
		contentUrl : "assets://sample.m4v"
	});
page1.add(video1);
video1.initialPlaybackTime = 15;
video1.playVideo();

var video1 = new SMF.UI.Video({
		left : "10%",
		top : "10%",
		contentUrl : "assets://localVideo.mpg"
	});
video1.playVideo(true, true, function () {
	alert("playybackStarrted.");
}, function () {
	alert("video Initialized.");
}, function () {
	alert("playyback Completed.");
}, function () {
	alert("Error");
});

Properties

NAMEDESCRIPTION
contentUrl
Allows user to enter the link of video.
controlStyle
Allows you to specify control styles
enabled
Sets the enable feature of the selected object.
height
Specifies the height of the the selected object.
initialPlaybackTime
Allows you to enter initial play time.
left
Specifies the position of the left side of the selected object
lockAutoPosition
Locks the position of the control in a contained object.
lockAutoSize
Locks the size of the video object so that its position won’t be changed during the design process.Checked:Locks the object.Unchecked:Unlocks the object.
movieScalingMode
Allows you to set scale modes which enable to scale of the video.
name
A reference name which is not displayed when the application is running. Set a logical name for each object, so you can easily identify later. You can not use small letters,space and punctuation marks except comma and full stop.
top
Specifies the position of the top of the selected object.
touchEnabled
Sets the touch feature of the selected object.
type
Returns the type of the component in string.
visible
Shows or hides the object.True:Enables the feature.
width
Specifies the width of the selected object.

Here is an example for initialPlaybackTime property of Video :

var video1 = new SMF.UI.Video({
		left : "10%",
		top : "10%",
		width : "80%",
		height : "40%",
		controlStyle : SMF.UI.VideoControlStyle.EMBEDDED,
		contentUrl : "assets://sample.m4v"
	});
page1.add(video1);
video1.initialPlaybackTime = 15;
video1.playVideo();

Events

NAMEDESCRIPTION
onHide
Creates action(s) that are run when the object is disappeared on the page.
onShow
Creates action(s) that are run when the object is appeared on the page.
onTouch
Creates action(s) that are run when the object is touched from device’s screen.
onTouchEnded
Creates action(s) that are run when the touching is ended.