Exemplo n.º 1
0
 public void setMusicImg() {
   MusicItem music = MusicData.getNowPlayingMusic();
   if (getMusicImg(music.getAlbumArtURI()) == null) {
     mMusicImg.setImageResource(R.drawable.phone_music_album_default);
   } else {
     mMusicImg.setImageBitmap(getMusicImg(music.getAlbumArtURI()));
   }
 }
Exemplo n.º 2
0
 public void updateMusicInfo() {
   MusicItem music = MusicData.getNowPlayingMusic();
   mArtistTextView.setText(music.getArtist());
   mTitleTextView.setText(music.getTitle());
   mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration())));
   mMusicProgress.setMax(Integer.parseInt(music.getDuration()));
   setMusicImg();
 }
Exemplo n.º 3
0
 @Override
 public void onClick(View v) {
   if (mIsDLNAConnected) {
     if (LocalMediaUtil.getWhichOnRemote() != LocalMediaUtil.Defs.MUSIC) {
       MusicItem music = MusicData.getNowPlayingMusic();
       try {
         LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.MUSIC);
         mPostButton.setClickable(false);
         mMusicPlayService.pause();
         //							mMusicPlayService.setPlayOnPhone(false);
         //							mIsPlayOnLocal = false;
         mIsOnRemotePause = false;
         mMusicPlayService.postToRemote();
         Log.e(TAG, music.getItemUri());
         postSeek(mMusicPlayService.position() + "");
         //							Log.d(TAG, "isPlayOnPhone" + mIsPlayOnLocal);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
     } else {
       //					mIsPlayOnLocal = true;
       poststop();
       LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.NOT_ANY_ONE);
       try {
         //						mMusicPlayService.setPlayOnPhone(true);
         mMusicPlayService.play();
         mMusicPlayService.seekTo(mRemotePlayPosition);
       } catch (RemoteException e) {
         e.printStackTrace();
       }
       try {
         if (mMusicPlayService.isPlaying()) {
           mStatusButton.setImageResource(R.drawable.video_btn_pause);
         } else {
           mStatusButton.setImageResource(R.drawable.video_btn_start);
         }
       } catch (RemoteException e) {
         e.printStackTrace();
       }
     }
   } else {
     Toast.makeText(
             getApplicationContext(),
             R.string.video_not_connection_toast_message,
             Toast.LENGTH_SHORT)
         .show();
   }
 }
Exemplo n.º 4
0
 public void doClick(View view) throws RemoteException {
   switch (view.getId()) {
     case R.id.pause_play:
       if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) {
         if (mIsOnRemotePause) {
           postPauseToPlay();
           mStatusButton.setImageResource(R.drawable.video_btn_pause);
           mIsOnRemotePause = false;
         } else {
           postpause();
           mStatusButton.setImageResource(R.drawable.video_btn_start);
           mIsOnRemotePause = true;
         }
       } else {
         mMusicPlayService.pauseButtonPressed();
       }
       break;
     case R.id.stop:
       if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) {
         poststop();
         LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.NOT_ANY_ONE);
         mIsOnRemotePause = true;
       }
       mMusicPlayService.stop();
       MusicData.setNowPlayingMusic(null);
       mMusicPlayService.setInitialed(false);
       finish();
       overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
       break;
     case R.id.next:
       mMusicPlayService.next();
       updateMusicInfo();
       if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) {
         MusicItem music = MusicData.getNowPlayingMusic();
         mMusicPlayService.pause();
         //				mMusicProgress.setMax((int) mMusicPlayService.duration());
         //				mArtistTextView.setText(music.getArtist());
         //				mTitleTextView.setText(music.getTitle());
         //				mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration())));
         postNext(music.getItemUri(), music.metaData);
       } else {
         if (mMusicPlayService.getPreparedStatus()) {
           mMusicPlayService.play();
         }
       }
       break;
     case R.id.prev:
       mMusicPlayService.prev();
       updateMusicInfo();
       if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) {
         MusicItem music = MusicData.getNowPlayingMusic();
         mMusicPlayService.pause();
         //				mMusicProgress.setMax((int) mMusicPlayService.duration());
         //				mArtistTextView.setText(music.getArtist());
         //				mTitleTextView.setText(music.getTitle());
         //				mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration())));
         postNext(music.getItemUri(), music.metaData);
       } else {
         if (mMusicPlayService.getPreparedStatus()) {
           mMusicPlayService.play();
         }
       }
       break;
     case R.id.post:
       break;
     case R.id.nowplayinglist:
       MusicData.setMusicShowList(MusicData.getMusicPlayList());
       Intent intent = new Intent();
       intent.putExtra("title", getResources().getString(R.string.playing_list));
       intent.putExtra("scrollto", true);
       intent.setClass(getApplicationContext(), MusicListActivity.class);
       startActivityForResult(intent, 0);
       overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
       break;
   }
 }