1 /* 2 * Copyright (C) 2011 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 17 package com.android.ex.variablespeed; 18 19 import android.content.Context; 20 import android.media.MediaPlayer; 21 import android.net.Uri; 22 23 import java.io.IOException; 24 25 /** 26 * Interface that supports a subset of the operations on {@link android.media.MediaPlayer}. 27 * 28 * <p>This subset is arbitrarily defined - at the moment it is the subset that the voicemail 29 * playback requires.</p> 30 * 31 * <p>This interface exists to make alternate implementations to the standard media player 32 * swappable, as well as making it much easier to test code that directly uses a media player. 33 */ 34 public interface MediaPlayerProxy { 35 void setOnErrorListener(MediaPlayer.OnErrorListener listener); 36 void setOnCompletionListener(MediaPlayer.OnCompletionListener listener); 37 void release(); 38 void reset(); 39 void setDataSource(String path) throws IllegalStateException, IOException; 40 void setDataSource(Context context, Uri intentUri) throws IllegalStateException, IOException; 41 void prepare() throws IOException; 42 int getDuration(); 43 void seekTo(int startPosition); 44 void start(); 45 boolean isReadyToPlay(); 46 boolean isPlaying(); 47 int getCurrentPosition(); 48 void pause(); 49 void setAudioStreamType(int streamType); 50 } 51