1 /* 2 * Copyright (C) 2014 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 android.support.v4.media.session; 18 19 import android.media.session.PlaybackState; 20 import android.os.SystemClock; 21 22 class PlaybackStateCompatApi21 { getState(Object stateObj)23 public static int getState(Object stateObj) { 24 return ((PlaybackState)stateObj).getState(); 25 } 26 getPosition(Object stateObj)27 public static long getPosition(Object stateObj) { 28 return ((PlaybackState)stateObj).getPosition(); 29 } 30 getBufferedPosition(Object stateObj)31 public static long getBufferedPosition(Object stateObj) { 32 return ((PlaybackState)stateObj).getBufferedPosition(); 33 } 34 getPlaybackSpeed(Object stateObj)35 public static float getPlaybackSpeed(Object stateObj) { 36 return ((PlaybackState)stateObj).getPlaybackSpeed(); 37 } 38 getActions(Object stateObj)39 public static long getActions(Object stateObj) { 40 return ((PlaybackState)stateObj).getActions(); 41 } 42 getErrorMessage(Object stateObj)43 public static CharSequence getErrorMessage(Object stateObj) { 44 return ((PlaybackState)stateObj).getErrorMessage(); 45 } 46 getLastPositionUpdateTime(Object stateObj)47 public static long getLastPositionUpdateTime(Object stateObj) { 48 return ((PlaybackState)stateObj).getLastPositionUpdateTime(); 49 } 50 newInstance(int state, long position, long bufferedPosition, float speed, long actions, CharSequence errorMessage, long updateTime)51 public static Object newInstance(int state, long position, long bufferedPosition, 52 float speed, long actions, CharSequence errorMessage, long updateTime) { 53 PlaybackState.Builder stateObj = new PlaybackState.Builder(); 54 stateObj.setState(state, position, speed, updateTime); 55 stateObj.setBufferedPosition(bufferedPosition); 56 stateObj.setActions(actions); 57 stateObj.setErrorMessage(errorMessage); 58 return stateObj.build(); 59 } 60 } 61