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