JavaScript API (In progress)

Amalia.js embeds API for control the player using JavaScript. Below you will find details of events and api functions.

Getting started


The sample HTML page below creates an embedded player that will load a video with button outside player to playback video.playback.


<html>

<head>

    <!-- 0. Add dependences -->

    <script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script>

    <script type="text/javascript" src="bower_components/jquery-ui/jquery-ui.min.js"></script>

    <script type="text/javascript" src="bower_components/raphael/raphael.js"></script>

    <link href="build/css/amalia.js.min.css" type="text/css" rel="stylesheet"/>

    <script src="build/js/amalia.js.min.js" type="text/javascript"></script>

</head>

<body>

<!-- 1. The <div> tag will contains the player. -->

<div id="player"></div>

<button onclick="playVideo()">Play</button>

<script>

    var player = null;

    // 2. Function to execute when the DOM is fully loaded

    $(document).ready(function () {

        // 3. Init player with default parameters

        $("#player").mediaPlayer({

            src: "samples-data/examples/vid/amalia01.mp4",

            callbacks: {

                onReady: 'onReady'

            }

        });



    });

    // 4. The API will call this function when the video player is ready.

    function onReady() {

        player = $('#player').data('fr.ina.amalia.player').getPlayer();

        // Set event listener on time change.

        $('#player').on('fr.ina.amalia.player.PlayerEventType.TIME_CHANGE', onTimeChange);



    }

    // 5. Function will call on click to button play

    function playVideo() {

        if (player !== null) {

            player.play();

        }

    }

    // 6. Function will call on time change event

    function onTimeChange(event, data) {



    }

</script>

</body>

</html>


Events


Event Name Description Data
fr.ina.amalia.player.PlayerEventType.INIT When the player has initialized
fr.ina.amalia.player.PlayerEventType.STARTED Fired when the player has started with duration
fr.ina.amalia.player.PlayerEventType.PLAYING Fires when playing event.
fr.ina.amalia.player.PlayerEventType.PAUSED Fires the paused/resumed
fr.ina.amalia.player.PlayerEventType.ENDED Ended event should fire when a video is completely.
fr.ina.amalia.player.PlayerEventType.MUTE Fired when the player has gone into mutes.
fr.ina.amalia.player.PlayerEventType.UN_MUTE Fired when the player has gone into unmutes.
fr.ina.amalia.player.PlayerEventType.VOLUME_CHANGE Fired when the player volume was changed
volume
Volume percentage
fr.ina.amalia.player.PlayerEventType.TIME_CHANGE This event is fired as the playback position gets updated.
currentTime
Playback position in seconds
percentage
Playback percentage
fr.ina.amalia.player.PlayerEventType.FULLSCREEN_CHANGE This fires when full-screen mode change
inFullScreen
fr.ina.amalia.player.PlayerEventType.SEEK Fired when the seeks.
currentTime
Playback position in seconds
fr.ina.amalia.player.PlayerEventType.ERROR Fired when a media error has occurred.
fr.ina.amalia.player.PlayerEventType.PLUGIN_READY Fired when the plugin has initialized.
fr.ina.amalia.player.PlayerEventType.PLUGIN_ERROR Fired when a plugin error has occurred.
fr.ina.amalia.player.PlayerEventType.DATA_CHANGE Fired when data change
id
Metadata block id.
fr.ina.amalia.player.PlayerEventType.BEGIN_DATA_CHANGE Fired when data change
fr.ina.amalia.player.PlayerEventType.END_DATA_CHANGE fired at the beginning of data change
fr.ina.amalia.player.PlayerEventType.IMAGE_CAPTURE Fired end of data change
captureTc
Capture position in seconds
captureId
Capture Id
captureImage
Image base 64
fr.ina.amalia.player.PlayerEventType.ZOOM_RANGE_CHANGE Fired end of data change
zTcin
Zoom Tc in
zTcout
Zoom Tc out
fr.ina.amalia.player.PlayerEventType.SELECTED_METADATA_CHANGE Fired on zoom range change
id
Metadata block id.
fr.ina.amalia.player.PlayerEventType.SELECTED_ITEMS_CHANGE Fired on select item
item
Selected Metadata block item
fr.ina.amalia.player.PlayerEventType.PLAYBACK_RATE_CHANGE Fired on playback rate change item
rate
Playback rate
fr.ina.amalia.player.PlayerEventType.START_SEEKING Fired when start seeking.
percentage
Percent seek
fr.ina.amalia.player.PlayerEventType.STOP_SEEKING Fired when stop seeking.
percentage
Percent seek
fr.ina.amalia.player.PlayerEventType.STOP_SEEKING Fired when seeking.
percentage
Percent seek

Functions


Name Description Parameters
play() Plays the currently video.
pause() Pauses the currently playing video.
isPaused() Returns true if the player is paused.
stop() Stops and cancels loading of the current video.
seek(time) Seek
time
Specified time in the video.
mute() Mutes the player.
unmute() Unmutes the player.
isMute() Returns true if the player is muted.
getTcOffset() Returns time offset.
getDuration() Returns the video duration.
getVolume() Returns the player's current volume, an integer between 0 and 100.
setVolume(value) Sets the volume.
value
The volume value, accepts an integer between 0 and 100.
rangePlay(tcin, tcout, autoplay) Playback ths specified time range.
tcin
Start Time
tcout
End Time
autoplay
getCurrentTime() Returns the current position with tcOffset.
setCurrentTime(value) Set the specified position
getPlaybackrate() This function retrieves the playback rate of the currently playing video.
setPlaybackrate(value) This function sets the suggested playback rate for the current video.
upPlaybackrate() Up the playback rate
downPlaybackrate() Down the playback rate
getFullscreen() Returns the current fullscreen state (true or false).
toggleFullScreen() Toogle the fullscreen state (true or false).
getCurrentImage() Return the current image of the video.
getTcImage() Return the specified position image of the video.
moveNextFrame() Move the next frame of the video.
movePrevFrame() Move the prev frame of the video.
addMenuItemWithLink(title, link, className) To Add the context menu item.
getBlockMetadata(id) Return the block of metadata.
id
Metadata block id.
getBlocksMetadata() Return all block of metadata.
updateBlockMetadata(id, data, action) Update the block metadata with the specified data.
id
Metadata block id.
data
parsed data
action
removeBlockMetadata(id) Remove the block metadata with specified id.
id
Metadata block id.
addAllMetadata(parsedData) Add metadata
id
Metadata block id.
addMetadataById(id, parsedData) Return the metadata for the specified id.
id
Metadata block id.
replaceAllMetadataById(id, parsedData) Replace metadata for the specified id.
id
Metadata block id.
parsedData
The metadata of a media stream.
deleteAllMetadataById(id) Delete the specified metadata.
id
Metadata block id.
getMetadataById(id) Return metadata for the specified id
id
Metadata block id.
setMetadataById(id, data) Set metadata by id
removeMetadataById(id) Remove metadata for the specified id
getMetadataWithRange(id, tcin, tcout) Return a metadata by specified time code.
id
Metadata block id.
tcin
Start time
tcout
End time
getSelectedMetadataId() Return selected metadata id.
id
Metadata block id.
setSelectedMetadataId(id) Set selected metadata id
id
Metadata block id.
addMetadataItem(metadataId, data) Add metadata item
getSelectedItems() Return selected items
addSelectedItem(item) Add selected item
removeAllSelectedItems() Remove all selected items
getTcin() Return tcin with tc offset
getTcout() Return Tcout with tcoffset and media duration
setZoomTc(zTcin, zTcout, eventTag) In charge to set zoom tc
zTcin
Zoom tc in
zTcout
Zoom tc out
eventTag
Tag name

Documentation