예제 #1
0
  private void bookmarkAudioBook() {
    AudioBook audioBook = AppController.getInstance().getCurrentAudioBook();
    Log.v("bookmarkAudioBook", "LastPlayFileIndex:" + audioBook.getLastPlayFileIndex());
    Log.v("bookmarkAudioBook", "LastSeekPoint:" + audioBook.getLastSeekPoint());

    DownloadedAudioBook downloadedAudioBook = new DownloadedAudioBook(context);
    downloadedAudioBook.addBookToList(context, audioBook.getBook_id(), audioBook);
  }
예제 #2
0
  public void stopAudioPlayer() {

    if (AudioPlayerService.mediaPlayer != null) {
      playPauseButton.setImageResource(R.drawable.btn_play_preview_start);
      sendStateChange("stop");
      AppController.getInstance().stopPlayer();
    }
  }
예제 #3
0
  public void updateView() {
    AudioBook audioBook = AppController.getInstance().getCurrentAudioBook();
    if (audioBook != null) {
      audioTitle.setText(audioBook.getEnglish_title());

      String img_path =
          AppUtils.getDataDirectory(context)
              + audioBook.getBook_id()
              + File.separator
              + "book_cover.jpg";

      File imgFile = new File(img_path);

      if (imgFile.exists()) {
        Picasso.with(context).load(imgFile).into(bookCoverImage);

      } else {
        Picasso.with(context)
            .load(audioBook.getCover_image())
            .placeholder(R.drawable.ic_launcher)
            .into(bookCoverImage);
      }
    }

    if (AudioPlayerService.mediaPlayer != null) {

      if (AudioPlayerService.mediaPlayer.isPlaying()) {
        playPauseButton.setImageResource(R.drawable.btn_play_preview_pause);

      } else {
        playPauseButton.setImageResource(R.drawable.btn_play_preview_start);
      }
    }

    subTitle.setText(AppController.getInstance().getPlayerControllerTitle());
  }
예제 #4
0
  void initViews(Context context, AttributeSet attrs) {
    this.context = context;

    LayoutInflater.from(context).inflate(R.layout.view_player_controller, this, true);
    playPauseButton = (ImageButton) this.findViewById(R.id.playPauseButton);
    bookCoverImage = (ImageView) this.findViewById(R.id.bookCoverImage);
    audioTitle = (TextView) this.findViewById(R.id.audioTitle);
    subTitle = (TextView) this.findViewById(R.id.subTitle);

    playPauseButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            playPauseAudio();
          }
        });
    AudioBook audioBook = AppController.getInstance().getCurrentAudioBook();
    if (audioBook != null) {
      audioTitle.setText(audioBook.getEnglish_title());

      String img_path =
          AppUtils.getDataDirectory(context)
              + audioBook.getBook_id()
              + File.separator
              + "book_cover.jpg";

      File imgFile = new File(img_path);

      if (imgFile.exists()) {
        Picasso.with(context).load(imgFile).into(bookCoverImage);

      } else {
        Picasso.with(context)
            .load(audioBook.getCover_image())
            .placeholder(R.drawable.ic_launcher)
            .into(bookCoverImage);
      }
    }

    updateView();
  }