1d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn/* 2d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * Copyright (C) 2013 The Android Open Source Project 3d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * 4d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 5d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * you may not use this file except in compliance with the License. 6d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * You may obtain a copy of the License at 7d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * 8d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 9d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * 10d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * Unless required by applicable law or agreed to in writing, software 11d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 12d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * See the License for the specific language governing permissions and 14d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn * limitations under the License. 15d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn */ 16d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 17d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackbornpackage android.support.v4.media; 18d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 19d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn/** 20e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Base interface to controlling a media transport. This is the 21e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * interface for implementing things like on-screen controls: it 22e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * allows them to request changes in playback, retrieve the current 23e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * playback state, and monitor for changes to the playback state. 24d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn */ 258c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackbornpublic abstract class TransportController { 26e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 27e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Start listening to changes in playback state. 28e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 298c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract void registerStateListener(TransportStateListener listener); 30d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 31e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 32e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Stop listening to changes in playback state. 33e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 348c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract void unregisterStateListener(TransportStateListener listener); 35d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 36e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 37e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Request that the player start its playback at its current position. 38e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 398c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract void startPlaying(); 40d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 41e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 42e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Request that the player pause its playback and stay at its current position. 43e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 448c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract void pausePlaying(); 45d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 46e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 47e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Request that the player stop its playback; it may clear its state in whatever 48e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * way is appropriate. 49e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 508c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract void stopPlaying(); 51d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 52e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 53e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Retrieve the total duration of the media stream, in milliseconds. 54e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 5554fe42a994b1aa1608d23a57a2f55228712e98e7Dianne Hackborn public abstract long getDuration(); 56d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn 57e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 58e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Retrieve the current playback location in the media stream, in milliseconds. 59e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 6054fe42a994b1aa1608d23a57a2f55228712e98e7Dianne Hackborn public abstract long getCurrentPosition(); 61c76d76a0d92a9dca5c91c68b86666d403ac0fd3cDianne Hackborn 62e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 63e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Move to a new location in the media stream. 64e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * @param pos Position to move to, in milliseconds. 65e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 6654fe42a994b1aa1608d23a57a2f55228712e98e7Dianne Hackborn public abstract void seekTo(long pos); 67c76d76a0d92a9dca5c91c68b86666d403ac0fd3cDianne Hackborn 68e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 69e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Return whether the player is currently playing its stream. 70e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 718c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract boolean isPlaying(); 72c76d76a0d92a9dca5c91c68b86666d403ac0fd3cDianne Hackborn 73e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 74e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Retrieve amount, in percentage (0-100), that the media stream has been buffered 75e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * on to the local device. Return 100 if the stream is always local. 76e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 778c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract int getBufferPercentage(); 78c76d76a0d92a9dca5c91c68b86666d403ac0fd3cDianne Hackborn 79e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn /** 80e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Retrieve the flags for the media transport control buttons that this transport supports. 81e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * Result is a combination of the following flags: 82e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_PREVIOUS}, 83e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_REWIND}, 84e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY}, 85e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_PLAY_PAUSE}, 86e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_PAUSE}, 87e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_STOP}, 88e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_FAST_FORWARD}, 89e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn * {@link TransportMediator#FLAG_KEY_MEDIA_NEXT} 90e3f8e5a462e23399945e8042ddb8025ec8fa33acDianne Hackborn */ 918c7c4c0409bd93f66fe39c5a5298a94f832be31eDianne Hackborn public abstract int getTransportControlFlags(); 92d3a70800e5f2cc2855d53ebea82fb7568affe02aDianne Hackborn} 93