103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar/* 203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Copyright (C) 2013 The Android Open Source Project 303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Licensed under the Apache License, Version 2.0 (the "License"); 503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * you may not use this file except in compliance with the License. 603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * You may obtain a copy of the License at 703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * http://www.apache.org/licenses/LICENSE-2.0 903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 1003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Unless required by applicable law or agreed to in writing, software 1103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * distributed under the License is distributed on an "AS IS" BASIS, 1203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * See the License for the specific language governing permissions and 1403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * limitations under the License. 1503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 1603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 1703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnarpackage android.media; 1803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 1903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar/** @hide */ 2003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnarpublic interface MediaTimeProvider { 2103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar // we do not allow negative media time 2203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 2303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Presentation time value if no timed event notification is requested. 2403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 2503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public final static long NO_TIME = -1; 2603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 2703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 2803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Cancels all previous notification request from this listener if any. It 2903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * registers the listener to get seek and stop notifications. If timeUs is 3003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * not negative, it also registers the listener for a timed event 3103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * notification when the presentation time reaches (becomes greater) than 3203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * the value specified. This happens immediately if the current media time 3303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * is larger than or equal to timeUs. 3403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 3503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * @param timeUs presentation time to get timed event callback at (or 3603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * {@link #NO_TIME}) 3703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 3803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public void notifyAt(long timeUs, OnMediaTimeListener listener); 3903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 4003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 4103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Cancels all previous notification request from this listener if any. It 4203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * registers the listener to get seek and stop notifications. If the media 4303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * is stopped, the listener will immediately receive a stop notification. 4403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Otherwise, it will receive a timed event notificaton. 4503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 4603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public void scheduleUpdate(OnMediaTimeListener listener); 4703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 4803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 4903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Cancels all previous notification request from this listener if any. 5003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 5103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public void cancelNotifications(OnMediaTimeListener listener); 5203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 5303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 5403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Get the current presentation time. 5503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 5603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * @param precise Whether getting a precise time is important. This is 5703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * more costly. 5803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * @param monotonic Whether returned time should be monotonic: that is, 5903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * greater than or equal to the last returned time. Don't 6003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * always set this to true. E.g. this has undesired 6103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * consequences if the media is seeked between calls. 62295659002ae490481798a16e39b5f88e80a8151eBen Murdoch * @throws IllegalStateException if the media is not initialized 6303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 6403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public long getCurrentTimeUs(boolean precise, boolean monotonic) 6503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar throws IllegalStateException; 6603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 6703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** @hide */ 6803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar public static interface OnMediaTimeListener { 6903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 7003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Called when the registered time was reached naturally. 7103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 7203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * @param timeUs current media time 7303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 7403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar void onTimedEvent(long timeUs); 7503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 7603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 7703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Called when the media time changed due to seeking. 7803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * 7903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * @param timeUs current media time 8003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 8103c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar void onSeek(long timeUs); 8203c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 8303c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar /** 8403c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * Called when the playback stopped. This is not called on pause, only 8503c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar * on full stop, at which point there is no further current media time. 8603c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar */ 8703c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar void onStop(); 8803c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar } 8903c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar} 9003c25794b66b0d01e0e850042713f8009c787dc2Lajos Molnar 91