コード例 #1
0
  private void updateTitle(boolean shutdown) {
    SongDetail mSongDetail = MediaController.getInstance().getPlayingSongDetail();
    if (mSongDetail == null && shutdown) {
      return;
    } else {
      updateProgress(mSongDetail);
      if (MediaController.getInstance().isAudioPaused()) {
        btn_playpausePanel.Pause();
        btn_playpause.Pause();
      } else {
        btn_playpausePanel.Play();
        btn_playpause.Play();
      }
      SongDetail audioInfo = MediaController.getInstance().getPlayingSongDetail();
      loadSongsDetails(audioInfo);

      if (txt_timetotal != null) {
        long duration = Long.valueOf(audioInfo.getDuration());
        txt_timetotal.setText(
            duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--");
      }
    }
  }
コード例 #2
0
  public void loadSongsDetails(SongDetail mDetail) {
    String contentURI = "content://media/external/audio/media/" + mDetail.getId() + "/albumart";
    imageLoader.displayImage(contentURI, songAlbumbg, options, animateFirstListener);
    imageLoader.displayImage(contentURI, img_bottom_slideone, options, animateFirstListener);
    imageLoader.displayImage(contentURI, img_bottom_slidetwo, options, animateFirstListener);

    txt_playesongname.setText(mDetail.getTitle());
    txt_songartistname.setText(mDetail.getArtist());
    txt_playesongname_slidetoptwo.setText(mDetail.getTitle());
    txt_songartistname_slidetoptwo.setText(mDetail.getArtist());

    if (txt_timetotal != null) {
      long duration = Long.valueOf(mDetail.getDuration());
      txt_timetotal.setText(
          duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--");
    }
    updateProgress(mDetail);
  }
コード例 #3
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

      ViewHolder mViewHolder;
      if (convertView == null) {
        mViewHolder = new ViewHolder();
        convertView = layoutInflater.inflate(R.layout.item_song, null);
        mViewHolder.song_row = (LinearLayout) convertView.findViewById(R.id.song_row);
        mViewHolder.textViewSongName = (TextView) convertView.findViewById(R.id.song_name);
        mViewHolder.textViewSongArtisNameAndDuration =
            (TextView) convertView.findViewById(R.id.song_details);
        mViewHolder.imageSongThm = (ImageView) convertView.findViewById(R.id.song_icon_art);
        mViewHolder.imagemore = (ImageView) convertView.findViewById(R.id.song_icon_option_more);
        convertView.setTag(mViewHolder);
      } else {
        mViewHolder = (ViewHolder) convertView.getTag();
      }
      SongDetail mDetail = songList.get(position);

      String audioDuration = "";
      try {
        audioDuration = DMPlayerUtility.getAudioDuration(Long.parseLong(mDetail.getDuration()));
      } catch (NumberFormatException e) {
        e.printStackTrace();
      }

      mViewHolder.textViewSongArtisNameAndDuration.setText(
          (audioDuration.isEmpty() ? "" : audioDuration + " | ") + mDetail.getArtist());
      mViewHolder.textViewSongName.setText(mDetail.getTitle());
      String contentURI = "content://media/external/audio/media/" + mDetail.getId() + "/albumart";
      imageLoader.displayImage(contentURI, mViewHolder.imageSongThm, options);

      convertView.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {

              SongDetail mDetail = songList.get(position);
              if (mDetail != null) {
                if (MediaController.getInstance().isPlayingAudio(mDetail)
                    && !MediaController.getInstance().isAudioPaused()) {
                  MediaController.getInstance().pauseAudio(mDetail);
                } else {
                  MediaController.getInstance()
                      .setPlaylist(songList, mDetail, (int) tagFor, (int) id);
                }
              }
            }
          });
      mViewHolder.imagemore.setColorFilter(Color.DKGRAY);
      mViewHolder.imagemore.setImageAlpha(255);

      mViewHolder.imagemore.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              try {
                PopupMenu popup = new PopupMenu(context, v);
                popup.getMenuInflater().inflate(R.menu.list_item_option, popup.getMenu());
                popup.show();
                popup.setOnMenuItemClickListener(
                    new PopupMenu.OnMenuItemClickListener() {
                      @Override
                      public boolean onMenuItemClick(MenuItem item) {

                        switch (item.getItemId()) {
                          case R.id.playnext:
                            break;
                          case R.id.addtoque:
                            break;
                          case R.id.addtoplaylist:
                            break;
                          case R.id.gotoartis:
                            break;
                          case R.id.gotoalbum:
                            break;
                          case R.id.delete:
                            break;
                          default:
                            break;
                        }

                        return true;
                      }
                    });
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });
      return convertView;
    }