Source: decorators/player/interface.js

define('application/decorators/player/interface', [
    'application/decorators/player/interfaces/playerinterface',
    'rofl/lib/utils',
    'rofl/class',
    'rofl/devices/mediaplayer/mediaplayer',
    'antie/runtimecontext'
], function (
    AppcorePlaybackInterface,
    Utils,
    Class,
    MediaPlayer,
    RuntimeContext
) {
    'use strict';

    var device = RuntimeContext.getCurrentApplication().getDevice(),
        deviceBrand = device.getBrand(),
        mediaplayer = device.getMediaPlayer();

    return AppcorePlaybackInterface.extend({

        /**
         * Attepmts to play the given player properties from media source.
         *
         * @param {Object} playerProperties - Contains player properties such as source..
         */
        play: function (playerProperties) {
            var mediaSource = this.mediaSource,
                programStartTime = playerProperties && playerProperties.programStartTime,
                startTime = playerProperties && playerProperties.startTime || programStartTime,
                delayedStartTime = playerProperties && playerProperties.delayedStartTime || 0,
                pauseTime = playerProperties && playerProperties.pauseTime || 0,
                async = playerProperties && playerProperties.async,
                zeroBasedStartTime = ((pauseTime - (delayedStartTime * 1000) - programStartTime) / 1000),
                timestampBasedStartTime = startTime || programStartTime;

            // Used for restart playback.
            this._programStartTime = programStartTime;

            if (deviceBrand === 'samsung') {
                startTime = zeroBasedStartTime || 1;
            } else {
                startTime = startTime !== programStartTime ? startTime : timestampBasedStartTime / 1000;
            }

            if (playerProperties.source !== this.source) {

                // Source has changed since last time, there's another source coming up so discard playback.
                return;
            }

            if (!mediaSource) {
                throw 'MediaSource missing from player';
            }

            if (!this.isPlaying()) {

                if (this.isLive()) {

                    // LIVE playback.
                    mediaplayer.beginLivePlayback({
                        async: async
                    });
                } else {

                    // StartOver playback.
                    mediaplayer.beginPlaybackFrom(startTime, {
                        async: async
                    });
                }
            }
        },

        /**
         * Seeks to the given value. Available for restart type only.
         *
         * @param {number} value - The time that the media player should attempt to play from.
         */
        seek: function (value) {
            var seekTo;

            if (!this.isLive()) {
                if (deviceBrand === 'samsung') {
                    seekTo = value;
                } else {
                    seekTo = value || this._programStartTime / 1000;
                }

                mediaplayer.playFrom(seekTo);
            }
        }
    });
});