javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/StopTimeControl.java
changeset 26 dc7c549001d5
parent 23 98ccebc37403
child 35 85266cc22c7f
equal deleted inserted replaced
23:98ccebc37403 26:dc7c549001d5
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description: StopTimeControl
    15 *
    15 *
    16 */
    16 */
    17 /**
    17 
    18  * 
       
    19  */
       
    20 package com.nokia.microedition.media.animation;
    18 package com.nokia.microedition.media.animation;
    21 
    19 
    22 import javax.microedition.media.Player;
    20 import javax.microedition.media.Player;
    23 
    21 
    24 import com.nokia.microedition.media.control.ControlImpl;
    22 import com.nokia.microedition.media.control.ControlImpl;
    25 
    23 
       
    24 
    26 /**
    25 /**
    27  * @author d35kumar
    26  * <code>StopTimeControl</code> allows one to specify a preset stop time for
    28  *
    27  * a <code>Player</code>.
       
    28  * <p>
    29  */
    29  */
    30 public class StopTimeControl extends ControlImpl implements
    30 public class StopTimeControl extends ControlImpl implements
    31 		javax.microedition.media.control.StopTimeControl {
    31 		javax.microedition.media.control.StopTimeControl {
    32 
    32 
    33 	long iStopTime=RESET;
    33 	private long iStopTime=RESET;
    34 	/**
    34 	/**
    35 	 * 
    35 	 * 
    36 	 */
    36 	 */
    37 	public StopTimeControl(Player aPlayer) {
    37 	public StopTimeControl(Player aPlayer) {
    38 		this.iPlayer=aPlayer;
    38 		this.iPlayer=aPlayer;
    39 	}
    39 	}
    40 
    40 
    41 	/* (non-Javadoc)
    41 	/**
    42 	 * @see javax.microedition.media.control.StopTimeControl#getStopTime()
    42      * Gets the last value successfully set by <CODE>setStopTime</CODE>.
    43 	 */
    43      *
       
    44      * Returns the constant <CODE>RESET</CODE> if no stop time is set.
       
    45      * This is the default.
       
    46      *
       
    47      * @return The current stop time in microseconds.
       
    48      * @see #setStopTime
       
    49      */
    44 	public long getStopTime() {
    50 	public long getStopTime() {
    45 		 checkState();
    51 		 checkState();
    46 		return iStopTime;
    52 		return iStopTime;
    47 	}
    53 	}
    48 
    54 
    49 	/* (non-Javadoc)
    55 	 /**
    50 	 * @see javax.microedition.media.control.StopTimeControl#setStopTime(long)
    56     *
    51 	 */
    57     * Sets the <i>media time</i> at which you want the <code>Player</code>
       
    58     * to stop.
       
    59     * The <code>Player</code> will stop when its <i>media time</i>
       
    60     * reaches the stop-time.
       
    61     * A <code>STOPPED_AT_TIME</code> event
       
    62     * will be delivered through the <code>PlayerListener</code>.
       
    63     * <p>
       
    64     * The <code>Player</code> is guaranteed
       
    65     * to stop within one second past the preset stop-time
       
    66     * (i.e. <code>stop-time <= current-media-time <= stop-time + 1 sec.</code>);
       
    67     * unless the current media time is already passed the preset stop time
       
    68     * when the stop time is set.
       
    69     * If the current media time is already past the stop time set,
       
    70     * the <code>Player</code> will stop immediately.  A
       
    71     * <code>STOPPED_AT_TIME</code> event will be delivered.
       
    72     * After the <code>Player</code> stops due to the stop-time set,
       
    73     * the previously set stop-time will be cleared automatically.
       
    74     * Alternatively, the stop time can be explicitly removed by
       
    75     * setting it to: <code>RESET</code>.
       
    76     * <p>
       
    77     *
       
    78     * You can always call <code>setStopTime</code> on a stopped
       
    79     * <code>Player</code>.
       
    80     * To avoid a potential race condition, it is illegal to
       
    81     * call <code>setStopTime</code> on a started <code>Player</code> if a
       
    82     * <i>media stop-time</i> has already been set.
       
    83     *
       
    84     * @param aStopTime The time in microseconds at which you want the
       
    85     * <code>Player</code> to stop, in <i>media time</i>.
       
    86     * @exception IllegalStateException Thrown if
       
    87     * <code>aStopTime</code> is called on a started
       
    88     * <code>Player</code> and the
       
    89     * <i>media stop-time</i> has already been set.
       
    90     * @see #getStopTime
       
    91     */
    52 	public void setStopTime(long aStopTime) {
    92 	public void setStopTime(long aStopTime) {
    53 		checkState();
    93 		checkState();
    54 		if (iPlayer.getState() == Player.STARTED && getStopTime() != RESET) {
    94 		if (iPlayer.getState() == Player.STARTED && getStopTime() != RESET) {
    55 			throw new IllegalStateException(
    95 			throw new IllegalStateException(
    56 					"Player is STARTED or setStopTime() is already called successfully");
    96 					"Player is STARTED or setStopTime() is already called successfully");
    57 		}
    97 		}
    58 		iStopTime = aStopTime;
    98 		iStopTime = aStopTime;
       
    99 		((AnimationPlayer)iPlayer).setiStopTime(iStopTime);
    59 	}
   100 	}
    60 }
   101 }