use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.
the class FolderPresenter method addFolderToPlayList.
@Override
public void addFolderToPlayList(final Folder folder, PlayList playList) {
if (folder.getSongs().isEmpty())
return;
if (playList.isFavorite()) {
for (Song song : folder.getSongs()) {
song.setFavorite(true);
}
}
playList.addSong(folder.getSongs(), 0);
Subscription subscription = mRepository.update(playList).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber<PlayList>() {
@Override
public void onStart() {
mView.showLoading();
}
@Override
public void onCompleted() {
mView.hideLoading();
}
@Override
public void onError(Throwable e) {
mView.hideLoading();
mView.handleError(e);
}
@Override
public void onNext(PlayList playList) {
RxBus.getInstance().post(new PlayListUpdatedEvent(playList));
}
});
mSubscriptions.add(subscription);
}
use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.
the class FileUtils method folderFromDir.
public static Folder folderFromDir(File dir) {
Folder folder = new Folder(dir.getName(), dir.getAbsolutePath());
List<Song> songs = musicFiles(dir);
folder.setSongs(songs);
folder.setNumOfSongs(songs.size());
return folder;
}
use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.
the class PlaybackService method updateRemoteViews.
private void updateRemoteViews(RemoteViews remoteView) {
Song currentSong = mPlayer.getPlayingSong();
if (currentSong != null) {
remoteView.setTextViewText(R.id.text_view_name, currentSong.getDisplayName());
remoteView.setTextViewText(R.id.text_view_artist, currentSong.getArtist());
}
remoteView.setImageViewResource(R.id.image_view_play_toggle, isPlaying() ? R.drawable.ic_remote_view_pause : R.drawable.ic_remote_view_play);
Bitmap album = AlbumUtils.parseAlbum(getPlayingSong());
if (album == null) {
remoteView.setImageViewResource(R.id.image_view_album, R.mipmap.ic_launcher);
} else {
remoteView.setImageViewBitmap(R.id.image_view_album, album);
}
}
use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.
the class Player method play.
@Override
public boolean play() {
if (isPaused) {
mPlayer.start();
notifyPlayStatusChanged(true);
return true;
}
if (mPlayList.prepare()) {
Song song = mPlayList.getCurrentSong();
try {
mPlayer.reset();
mPlayer.setDataSource(song.getPath());
mPlayer.prepare();
mPlayer.start();
notifyPlayStatusChanged(true);
} catch (IOException e) {
Log.e(TAG, "play: ", e);
notifyPlayStatusChanged(false);
return false;
}
return true;
}
return false;
}
use of io.github.ryanhoo.music.data.model.Song in project StylishMusicPlayer by ryanhoo.
the class Player method playLast.
@Override
public boolean playLast() {
isPaused = false;
boolean hasLast = mPlayList.hasLast();
if (hasLast) {
Song last = mPlayList.last();
play();
notifyPlayLast(last);
return true;
}
return false;
}
Aggregations