// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java
// public class AudioStoppedEvent {}
// 
// Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java
// public class AudioPlayerNotification {
//   private final Context context;
//   private final Notification.Builder notificationBuilder;
// 
//   protected static final String REWIND = "Rewind";
//   protected static final String PAUSE = "Pause";
//   protected static final String STOP = "Stop";
//   protected static final String FAST_FORWARD = "Fast Forward";
// 
//   @Inject
//   public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) {
//     this.context = context;
//     this.notificationBuilder = notificationBuilder;
//   }
// 
//   public Notification buildNotification(Episode episode) {
//     Notification.MediaStyle mediaStyle = new Notification.MediaStyle();
// 
//     return notificationBuilder
//         .setSmallIcon(R.drawable.ic_av_play_circle_fill)
//         .setContentTitle(episode.getFeed().getTitle())
//         .setContentText(episode.getTitle())
//         .setStyle(mediaStyle)
//         .setVisibility(Notification.VISIBILITY_PUBLIC)
//         .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND))
//         .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE))
//         .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP))
//         .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD))
//         .build();
//   }
// 
//   private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) {
//     Intent intent = new Intent(context, AudioPlayerService.class);
//     intent.setAction(intentAction);
// 
//     intent.putExtra(Episode.class.toString(), episode);
// 
//     PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT);
// 
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//       return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build();
//     } else {
//       return new Notification.Action.Builder(icon, title, pendingIntent).build();
//     }
//   }
// }
// 
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java
// public class Episode implements Serializable {
// 
//   private String title;
//   private String publishedDate;
//   private String description;
//   private String duration;
//   private Audio audio;
//   private Feed podcast;
//   private Image image;
// 
//   public Image getImage() {
//     return image;
//   }
// 
//   public String getTitle() {
//     return title;
//   }
// 
//   public Date getPublishedDate() {
//     if (publishedDate == null) { return null; }
// 
//     return dateTimeParser().parseDateTime(publishedDate).toDate();
//   }
// 
//   public String getDescription() {
//     return description == null ? "" : description;
//   }
// 
//   public String getDuration() {
//     return duration;
//   }
// 
//   public Feed getFeed() {
//     if (podcast == null) { return new Feed(); }
// 
//     return podcast;
//   }
// 
//   public String getAudioFilePath() {
//     return getFeed().getId() + "/" + getTitle() + ".mp3";
//   }
// 
//   public String getAudioUrl() {
//     return getAudio().getUrl();
//   }
// 
//   public String getAudioLength() {
//     return getAudio().getLength();
//   }
// 
//   protected Audio getAudio() {
//     if (audio == null) { return new EmptyAudio(); }
// 
//     return audio;
//   }
// 
//   @Override
//   public String toString() {
//     return format(
//         "{ \"title\": %s, " +
//             "\"audioFilePath\": %s, " +
//             "\"feed\": { \"id\": %s, \"title\": %s } " +
//         "}",
//         getTitle(),
//         getAudioFilePath(),
//         getFeed().getId(),
//         getFeed().getTitle()
//     );
//   }
// 
//   private class EmptyAudio extends Audio {
//     @Override
//     public String getUrl() {
//       return "";
//     }
// 
//     @Override
//     public String getLength() {
//       return "0";
//     }
//   }
// }
// 
// Path: app/src/main/java/com/mypodcasts/support/Support.java
// public class Support {
//   public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
// }
// 
// Path: app/src/main/java/com/mypodcasts/support/Support.java
// public static final String MYPODCASTS_TAG = "[mypodcasts-android]";


import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import com.mypodcasts.player.events.AudioStoppedEvent;
import com.mypodcasts.player.notification.AudioPlayerNotification;
import com.mypodcasts.repositories.models.Episode;
import com.mypodcasts.support.Support;
import java.io.IOException;
import javax.inject.Inject;
import org.greenrobot.eventbus.EventBus;
import roboguice.service.RoboService;
import static com.mypodcasts.support.Support.MYPODCASTS_TAG;
package com.mypodcasts.player;







public class AudioPlayerService extends RoboService {

  public static final int ONGOING_NOTIFICATION_ID = 1;

  public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind";
  public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause";
  public static final String ACTION_PLAY = "com.mypodcasts.player.action.play";
  public static final String ACTION_STOP = "com.mypodcasts.player.action.stop";
  public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward";
  public static final int POSITION = 25 * 1000;

  @Inject
  private Context context;

  @Inject
  private AudioPlayer audioPlayer;

  @Inject
// Path: app/src/main/java/com/mypodcasts/player/events/AudioStoppedEvent.java
// public class AudioStoppedEvent {}
// 
// Path: app/src/main/java/com/mypodcasts/player/notification/AudioPlayerNotification.java
// public class AudioPlayerNotification {
//   private final Context context;
//   private final Notification.Builder notificationBuilder;
// 
//   protected static final String REWIND = "Rewind";
//   protected static final String PAUSE = "Pause";
//   protected static final String STOP = "Stop";
//   protected static final String FAST_FORWARD = "Fast Forward";
// 
//   @Inject
//   public AudioPlayerNotification(Context context, Notification.Builder notificationBuilder) {
//     this.context = context;
//     this.notificationBuilder = notificationBuilder;
//   }
// 
//   public Notification buildNotification(Episode episode) {
//     Notification.MediaStyle mediaStyle = new Notification.MediaStyle();
// 
//     return notificationBuilder
//         .setSmallIcon(R.drawable.ic_av_play_circle_fill)
//         .setContentTitle(episode.getFeed().getTitle())
//         .setContentText(episode.getTitle())
//         .setStyle(mediaStyle)
//         .setVisibility(Notification.VISIBILITY_PUBLIC)
//         .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND))
//         .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE))
//         .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP))
//         .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD))
//         .build();
//   }
// 
//   private Notification.Action generateAction(Episode episode, int icon, String title, String intentAction) {
//     Intent intent = new Intent(context, AudioPlayerService.class);
//     intent.setAction(intentAction);
// 
//     intent.putExtra(Episode.class.toString(), episode);
// 
//     PendingIntent pendingIntent = PendingIntent.getService(context, 1, intent, FLAG_UPDATE_CURRENT);
// 
//     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//       return new Notification.Action.Builder(Icon.createWithResource("", icon), title, pendingIntent).build();
//     } else {
//       return new Notification.Action.Builder(icon, title, pendingIntent).build();
//     }
//   }
// }
// 
// Path: app/src/main/java/com/mypodcasts/repositories/models/Episode.java
// public class Episode implements Serializable {
// 
//   private String title;
//   private String publishedDate;
//   private String description;
//   private String duration;
//   private Audio audio;
//   private Feed podcast;
//   private Image image;
// 
//   public Image getImage() {
//     return image;
//   }
// 
//   public String getTitle() {
//     return title;
//   }
// 
//   public Date getPublishedDate() {
//     if (publishedDate == null) { return null; }
// 
//     return dateTimeParser().parseDateTime(publishedDate).toDate();
//   }
// 
//   public String getDescription() {
//     return description == null ? "" : description;
//   }
// 
//   public String getDuration() {
//     return duration;
//   }
// 
//   public Feed getFeed() {
//     if (podcast == null) { return new Feed(); }
// 
//     return podcast;
//   }
// 
//   public String getAudioFilePath() {
//     return getFeed().getId() + "/" + getTitle() + ".mp3";
//   }
// 
//   public String getAudioUrl() {
//     return getAudio().getUrl();
//   }
// 
//   public String getAudioLength() {
//     return getAudio().getLength();
//   }
// 
//   protected Audio getAudio() {
//     if (audio == null) { return new EmptyAudio(); }
// 
//     return audio;
//   }
// 
//   @Override
//   public String toString() {
//     return format(
//         "{ \"title\": %s, " +
//             "\"audioFilePath\": %s, " +
//             "\"feed\": { \"id\": %s, \"title\": %s } " +
//         "}",
//         getTitle(),
//         getAudioFilePath(),
//         getFeed().getId(),
//         getFeed().getTitle()
//     );
//   }
// 
//   private class EmptyAudio extends Audio {
//     @Override
//     public String getUrl() {
//       return "";
//     }
// 
//     @Override
//     public String getLength() {
//       return "0";
//     }
//   }
// }
// 
// Path: app/src/main/java/com/mypodcasts/support/Support.java
// public class Support {
//   public static final String MYPODCASTS_TAG = "[mypodcasts-android]";
// }
// 
// Path: app/src/main/java/com/mypodcasts/support/Support.java
// public static final String MYPODCASTS_TAG = "[mypodcasts-android]";


// Path: app/src/main/java/com/mypodcasts/player/AudioPlayerService.java
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import com.mypodcasts.player.events.AudioStoppedEvent;
import com.mypodcasts.player.notification.AudioPlayerNotification;
import com.mypodcasts.repositories.models.Episode;
import com.mypodcasts.support.Support;
import java.io.IOException;
import javax.inject.Inject;
import org.greenrobot.eventbus.EventBus;
import roboguice.service.RoboService;
import static com.mypodcasts.support.Support.MYPODCASTS_TAG;

package com.mypodcasts.player;







public class AudioPlayerService extends RoboService {

  public static final int ONGOING_NOTIFICATION_ID = 1;

  public static final String ACTION_REWIND = "com.mypodcasts.player.action.rewind";
  public static final String ACTION_PAUSE = "com.mypodcasts.player.action.pause";
  public static final String ACTION_PLAY = "com.mypodcasts.player.action.play";
  public static final String ACTION_STOP = "com.mypodcasts.player.action.stop";
  public static final String ACTION_FAST_FORWARD = "com.mypodcasts.player.action.fast_foward";
  public static final int POSITION = 25 * 1000;

  @Inject
  private Context context;

  @Inject
  private AudioPlayer audioPlayer;

  @Inject
  private AudioPlayerNotification audioPlayerNotification;