Search in sources :

Example 16 with Song

use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.

the class MusicPlayerFragment method playSong.

private void playSong(PlayList playList, int playIndex) {
    if (playList == null)
        return;
    playList.setPlayMode(PreferenceManager.lastPlayMode(getActivity()));
    // boolean result =
    mPlayer.play(playList, playIndex);
    Song song = playList.getCurrentSong();
    onSongUpdated(song);
/*
        seekBarProgress.setProgress(0);
        seekBarProgress.setEnabled(result);
        textViewProgress.setText(R.string.mp_music_default_duration);

        if (result) {
            imageViewAlbum.startRotateAnimation();
            buttonPlayToggle.setImageResource(R.drawable.ic_pause);
            textViewDuration.setText(TimeUtils.formatDuration(song.getDuration()));
        } else {
            buttonPlayToggle.setImageResource(R.drawable.ic_play);
            textViewDuration.setText(R.string.mp_music_default_duration);
        }

        mHandler.removeCallbacks(mProgressCallback);
        mHandler.post(mProgressCallback);

        getActivity().startService(new Intent(getActivity(), PlaybackService.class));
        */
}
Also used : Song(io.github.ryanhoo.music.data.model.Song)

Example 17 with Song

use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.

the class MusicPlayerFragment method onPlaySongEvent.

private void onPlaySongEvent(PlaySongEvent event) {
    Song song = event.song;
    playSong(song);
}
Also used : Song(io.github.ryanhoo.music.data.model.Song)

Example 18 with Song

use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.

the class MusicPlayerPresenter method setSongAsFavorite.

@Override
public void setSongAsFavorite(Song song, boolean favorite) {
    Subscription subscription = mRepository.setSongAsFavorite(song, favorite).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<Song>() {

        @Override
        public void onCompleted() {
        // Empty
        }

        @Override
        public void onError(Throwable e) {
            mView.handleError(e);
        }

        @Override
        public void onNext(Song song) {
            mView.onSongSetAsFavorite(song);
            RxBus.getInstance().post(new FavoriteChangeEvent(song));
        }
    });
    mSubscriptions.add(subscription);
}
Also used : Song(io.github.ryanhoo.music.data.model.Song) FavoriteChangeEvent(io.github.ryanhoo.music.event.FavoriteChangeEvent) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription)

Aggregations

Song (io.github.ryanhoo.music.data.model.Song)18 Subscription (rx.Subscription)4 CompositeSubscription (rx.subscriptions.CompositeSubscription)4 PlayList (io.github.ryanhoo.music.data.model.PlayList)3 Folder (io.github.ryanhoo.music.data.model.Folder)2 File (java.io.File)2 List (java.util.List)2 Cursor (android.database.Cursor)1 Bitmap (android.graphics.Bitmap)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 OnClick (butterknife.OnClick)1 FavoriteChangeEvent (io.github.ryanhoo.music.event.FavoriteChangeEvent)1 PlayListUpdatedEvent (io.github.ryanhoo.music.event.PlayListUpdatedEvent)1 PlaySongEvent (io.github.ryanhoo.music.event.PlaySongEvent)1 OnItemClickListener (io.github.ryanhoo.music.ui.base.adapter.OnItemClickListener)1 DefaultDividerDecoration (io.github.ryanhoo.music.ui.common.DefaultDividerDecoration)1 AddToPlayListDialogFragment (io.github.ryanhoo.music.ui.playlist.AddToPlayListDialogFragment)1 IOException (java.io.IOException)1