MediaControllerCompatApi21.java 6.81 KB
package android.support.v4.media.session;

import android.annotation.TargetApi;
import android.content.Context;
import android.media.AudioAttributes;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.session.MediaController;
import android.media.session.MediaController.Callback;
import android.media.session.MediaController.PlaybackInfo;
import android.media.session.MediaController.TransportControls;
import android.media.session.MediaSession.QueueItem;
import android.media.session.MediaSession.Token;
import android.media.session.PlaybackState;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import java.util.List;

@TargetApi(21)
@RequiresApi(21)
final class MediaControllerCompatApi21
{
  public static Object a(Context paramContext, Object paramObject)
  {
    return new MediaController(paramContext, (MediaSession.Token)paramObject);
  }
  
  public static abstract interface Callback
  {
    public abstract void onAudioInfoChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5);
    
    public abstract void onExtrasChanged(Bundle paramBundle);
    
    public abstract void onMetadataChanged(Object paramObject);
    
    public abstract void onPlaybackStateChanged(Object paramObject);
    
    public abstract void onQueueChanged(List<?> paramList);
    
    public abstract void onQueueTitleChanged(CharSequence paramCharSequence);
    
    public abstract void onSessionDestroyed();
    
    public abstract void onSessionEvent(String paramString, Bundle paramBundle);
  }
  
  public static class PlaybackInfo
  {
    public static AudioAttributes getAudioAttributes(Object paramObject)
    {
      return ((MediaController.PlaybackInfo)paramObject).getAudioAttributes();
    }
    
    public static int getCurrentVolume(Object paramObject)
    {
      return ((MediaController.PlaybackInfo)paramObject).getCurrentVolume();
    }
    
    public static int getLegacyAudioStream(Object paramObject)
    {
      int i = 3;
      paramObject = getAudioAttributes(paramObject);
      if ((((AudioAttributes)paramObject).getFlags() & 0x1) == 1)
      {
        i = 7;
        return i;
      }
      if ((((AudioAttributes)paramObject).getFlags() & 0x4) == 4) {
        return 6;
      }
      switch (((AudioAttributes)paramObject).getUsage())
      {
      case 1: 
      case 11: 
      case 12: 
      case 14: 
      default: 
        return 3;
      case 2: 
        return 0;
      case 13: 
        return 1;
      case 3: 
        return 8;
      case 4: 
        return 4;
      case 6: 
        return 2;
      }
      return 5;
    }
    
    public static int getMaxVolume(Object paramObject)
    {
      return ((MediaController.PlaybackInfo)paramObject).getMaxVolume();
    }
    
    public static int getPlaybackType(Object paramObject)
    {
      return ((MediaController.PlaybackInfo)paramObject).getPlaybackType();
    }
    
    public static int getVolumeControl(Object paramObject)
    {
      return ((MediaController.PlaybackInfo)paramObject).getVolumeControl();
    }
  }
  
  public static class TransportControls
  {
    public static void fastForward(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).fastForward();
    }
    
    public static void pause(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).pause();
    }
    
    public static void play(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).play();
    }
    
    public static void playFromMediaId(Object paramObject, String paramString, Bundle paramBundle)
    {
      ((MediaController.TransportControls)paramObject).playFromMediaId(paramString, paramBundle);
    }
    
    public static void playFromSearch(Object paramObject, String paramString, Bundle paramBundle)
    {
      ((MediaController.TransportControls)paramObject).playFromSearch(paramString, paramBundle);
    }
    
    public static void rewind(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).rewind();
    }
    
    public static void seekTo(Object paramObject, long paramLong)
    {
      ((MediaController.TransportControls)paramObject).seekTo(paramLong);
    }
    
    public static void sendCustomAction(Object paramObject, String paramString, Bundle paramBundle)
    {
      ((MediaController.TransportControls)paramObject).sendCustomAction(paramString, paramBundle);
    }
    
    public static void setRating(Object paramObject1, Object paramObject2)
    {
      ((MediaController.TransportControls)paramObject1).setRating((Rating)paramObject2);
    }
    
    public static void skipToNext(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).skipToNext();
    }
    
    public static void skipToPrevious(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).skipToPrevious();
    }
    
    public static void skipToQueueItem(Object paramObject, long paramLong)
    {
      ((MediaController.TransportControls)paramObject).skipToQueueItem(paramLong);
    }
    
    public static void stop(Object paramObject)
    {
      ((MediaController.TransportControls)paramObject).stop();
    }
  }
  
  static final class a<T extends MediaControllerCompatApi21.Callback>
    extends MediaController.Callback
  {
    protected final T a;
    
    public a(T paramT)
    {
      this.a = paramT;
    }
    
    public final void onAudioInfoChanged(MediaController.PlaybackInfo paramPlaybackInfo)
    {
      this.a.onAudioInfoChanged(paramPlaybackInfo.getPlaybackType(), MediaControllerCompatApi21.PlaybackInfo.getLegacyAudioStream(paramPlaybackInfo), paramPlaybackInfo.getVolumeControl(), paramPlaybackInfo.getMaxVolume(), paramPlaybackInfo.getCurrentVolume());
    }
    
    public final void onExtrasChanged(Bundle paramBundle)
    {
      this.a.onExtrasChanged(paramBundle);
    }
    
    public final void onMetadataChanged(MediaMetadata paramMediaMetadata)
    {
      this.a.onMetadataChanged(paramMediaMetadata);
    }
    
    public final void onPlaybackStateChanged(PlaybackState paramPlaybackState)
    {
      this.a.onPlaybackStateChanged(paramPlaybackState);
    }
    
    public final void onQueueChanged(List<MediaSession.QueueItem> paramList)
    {
      this.a.onQueueChanged(paramList);
    }
    
    public final void onQueueTitleChanged(CharSequence paramCharSequence)
    {
      this.a.onQueueTitleChanged(paramCharSequence);
    }
    
    public final void onSessionDestroyed()
    {
      this.a.onSessionDestroyed();
    }
    
    public final void onSessionEvent(String paramString, Bundle paramBundle)
    {
      this.a.onSessionEvent(paramString, paramBundle);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/media/session/MediaControllerCompatApi21.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */