if (typeof QMI === "undefined" || !QMI) {
    var QMI = {};
}

if (typeof QMI.video === "undefined" || !QMI.video) {
    QMI.video = {};
}

/**
 * Creates a video player controller for the given player ID.
 * The player should be constructed using the "_video_player.jsp" file.
 * @param playerId the ID that was used to create the player Flash object.
 */
QMI.video.Player = function(playerId) {
    this.playerId = playerId;
};

/**
 * Loads and plays the given video (by its ID).
 * @param videoId the video ID.
 */
QMI.video.Player.prototype.play = function(videoId) {
    this._getBrightcovePlayer().loadVideo(videoId);
};

/**
 * Stops the currently playing video.
 */
QMI.video.Player.prototype.stop = function() {
    this._getBrightcovePlayer().stop();
};

/**
 * Retrieves the brightcove player associated with this instance.
 */
QMI.video.Player.prototype._getBrightcovePlayer = function() {
    var bcExp = brightcove.getExperience(this.playerId);
    return bcExp.getModule(APIModules.VIDEO_PLAYER);
};

