// Path: app/src/main/java/com/zsorg/neteasecloudmusic/CONST.java
// public class CONST {
//     public static final String MUSIC_TYPE = "MUSIC_TYPE";
//     public static final int TYPE_SINGLE = 0;
//     public static final int TYPE_SINGER = 1;
//     public static final int TYPE_ALBUM = 2;
//     public static final int TYPE_FOLDER = 3;
// 
//     public static final String INTENT_PLAYLIST_ID = "INTENT_PLAYLIST_ID";
//     public static final String INTENT_PLAYLIST_POSITION = "INTENT_PLAYLIST_POSITION";
// 
//     public static final int DEFAULT_PLAYLIST_POSITION = 0;
//     public static final int TEMP_PLAYLIST_ID = -1;
// 
//     public static final int IMAGE_LOADED = 1;
//     public static final int IMAGE_REQUEST_LOADING = 2;
//     public static final int PLAYLIST_FAVORITE = 0;
// 
//     public static final String SP_IS_FILTER_60 = "SP_IS_FILTER_60";
//     public static final String SP_MUSIC_ORDER = "SP_MUSIC_ORDER";
//     public static final int SP_MUSIC_ORDER_DEFAULT = 0;
//     public static final int MUSIC_ORDER_LIST = 0;
//     public static final int MUSIC_ORDER_SINGLE = 2;
//     public static final int MUSIC_ORDER_RANDOM = 1;
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/callbacks/OnTrackListener.java
// public interface OnTrackListener {
//     void onTrack(int position);
// 
//     void onNext(MusicBean bean);
// 
//     void onPlayStateChange(boolean isPlay);
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/models/beans/MusicBean.java
// public class MusicBean implements Parcelable{
//     private final String mSinger;
//     private final String mAlbum;
//     private String mPath;
//     private String mName;
//     private long mDuration;
// 
//     protected MusicBean(Parcel in) {
//         mSinger = in.readString();
//         mAlbum = in.readString();
//         mPath = in.readString();
//         mName = in.readString();
//         mDuration = in.readLong();
//     }
// 
//     public static final Creator<MusicBean> CREATOR = new Creator<MusicBean>() {
//         @Override
//         public MusicBean createFromParcel(Parcel in) {
//             return new MusicBean(in);
//         }
// 
//         @Override
//         public MusicBean[] newArray(int size) {
//             return new MusicBean[size];
//         }
//     };
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel parcel, int i) {
// 
//         parcel.writeString(mSinger);
//         parcel.writeString(mAlbum);
//         parcel.writeString(mPath);
//         parcel.writeString(mName);
//         parcel.writeLong(mDuration);
//     }
// 
//     @Override
//     public int hashCode() {
//         return mPath==null?0:mPath.hashCode();
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj instanceof MusicBean && (((MusicBean) obj).hashCode()==hashCode());
//     }
// 
//     public MusicBean(String name, String singer, String album, long duration, String path) {
//         mPath = path;
//         mName = name;
//         mSinger = singer;
//         mAlbum = album;
//         mDuration = duration;
//     }
// 
//     public String getSinger() {
//         return mSinger;
//     }
// 
//     public String getAlbum() {
//         return mAlbum;
//     }
// 
//     public String getPath() {
//         return mPath;
//     }
// 
//     public void setPath(String mPath) {
//         this.mPath = mPath;
//     }
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String mName) {
//         this.mName = mName;
//     }
// 
//     public long getDuration() {
//         return mDuration;
//     }
// 
//     public void setDuration(long mDuration) {
//         this.mDuration = mDuration;
//     }
// }


import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import com.zsorg.neteasecloudmusic.CONST;
import com.zsorg.neteasecloudmusic.callbacks.OnTrackListener;
import com.zsorg.neteasecloudmusic.models.beans.MusicBean;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
    public void nextMusic() {
        playMusicAtPosition(true);
    }

    public void playMusicAtPosition(boolean isNext) {
        if (null != mPlayer) {
            int i = isNext ? 1 : -1;
            if (mPosition+i < mCurrentPlaylist.size() && mPosition+i>=0) {
                mPosition+=i;
                try {
                    mPlayer.reset();
                    final MusicBean bean = mCurrentPlaylist.get(mPosition);
                    mPlayer.setDataSource(bean.getPath());
                    mPlayer.setOnCompletionListener(this);
                    mPlayer.prepare();
                    mPlayer.start();
                    if (null != onTrackListener) {
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                onTrackListener.onPlayStateChange(false);
                                onTrackListener.onNext(bean);
                                onTrackListener.onPlayStateChange(true);
                            }
                        });

                    }

                } catch (IOException e) {
                    e.printStackTrace();
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/CONST.java
// public class CONST {
//     public static final String MUSIC_TYPE = "MUSIC_TYPE";
//     public static final int TYPE_SINGLE = 0;
//     public static final int TYPE_SINGER = 1;
//     public static final int TYPE_ALBUM = 2;
//     public static final int TYPE_FOLDER = 3;
// 
//     public static final String INTENT_PLAYLIST_ID = "INTENT_PLAYLIST_ID";
//     public static final String INTENT_PLAYLIST_POSITION = "INTENT_PLAYLIST_POSITION";
// 
//     public static final int DEFAULT_PLAYLIST_POSITION = 0;
//     public static final int TEMP_PLAYLIST_ID = -1;
// 
//     public static final int IMAGE_LOADED = 1;
//     public static final int IMAGE_REQUEST_LOADING = 2;
//     public static final int PLAYLIST_FAVORITE = 0;
// 
//     public static final String SP_IS_FILTER_60 = "SP_IS_FILTER_60";
//     public static final String SP_MUSIC_ORDER = "SP_MUSIC_ORDER";
//     public static final int SP_MUSIC_ORDER_DEFAULT = 0;
//     public static final int MUSIC_ORDER_LIST = 0;
//     public static final int MUSIC_ORDER_SINGLE = 2;
//     public static final int MUSIC_ORDER_RANDOM = 1;
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/callbacks/OnTrackListener.java
// public interface OnTrackListener {
//     void onTrack(int position);
// 
//     void onNext(MusicBean bean);
// 
//     void onPlayStateChange(boolean isPlay);
// }
// 
// Path: app/src/main/java/com/zsorg/neteasecloudmusic/models/beans/MusicBean.java
// public class MusicBean implements Parcelable{
//     private final String mSinger;
//     private final String mAlbum;
//     private String mPath;
//     private String mName;
//     private long mDuration;
// 
//     protected MusicBean(Parcel in) {
//         mSinger = in.readString();
//         mAlbum = in.readString();
//         mPath = in.readString();
//         mName = in.readString();
//         mDuration = in.readLong();
//     }
// 
//     public static final Creator<MusicBean> CREATOR = new Creator<MusicBean>() {
//         @Override
//         public MusicBean createFromParcel(Parcel in) {
//             return new MusicBean(in);
//         }
// 
//         @Override
//         public MusicBean[] newArray(int size) {
//             return new MusicBean[size];
//         }
//     };
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel parcel, int i) {
// 
//         parcel.writeString(mSinger);
//         parcel.writeString(mAlbum);
//         parcel.writeString(mPath);
//         parcel.writeString(mName);
//         parcel.writeLong(mDuration);
//     }
// 
//     @Override
//     public int hashCode() {
//         return mPath==null?0:mPath.hashCode();
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj instanceof MusicBean && (((MusicBean) obj).hashCode()==hashCode());
//     }
// 
//     public MusicBean(String name, String singer, String album, long duration, String path) {
//         mPath = path;
//         mName = name;
//         mSinger = singer;
//         mAlbum = album;
//         mDuration = duration;
//     }
// 
//     public String getSinger() {
//         return mSinger;
//     }
// 
//     public String getAlbum() {
//         return mAlbum;
//     }
// 
//     public String getPath() {
//         return mPath;
//     }
// 
//     public void setPath(String mPath) {
//         this.mPath = mPath;
//     }
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String mName) {
//         this.mName = mName;
//     }
// 
//     public long getDuration() {
//         return mDuration;
//     }
// 
//     public void setDuration(long mDuration) {
//         this.mDuration = mDuration;
//     }
// }


// Path: app/src/main/java/com/zsorg/neteasecloudmusic/models/PlayerManager.java
import android.content.Context;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import com.zsorg.neteasecloudmusic.CONST;
import com.zsorg.neteasecloudmusic.callbacks.OnTrackListener;
import com.zsorg.neteasecloudmusic.models.beans.MusicBean;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

    public void nextMusic() {
        playMusicAtPosition(true);
    }

    public void playMusicAtPosition(boolean isNext) {
        if (null != mPlayer) {
            int i = isNext ? 1 : -1;
            if (mPosition+i < mCurrentPlaylist.size() && mPosition+i>=0) {
                mPosition+=i;
                try {
                    mPlayer.reset();
                    final MusicBean bean = mCurrentPlaylist.get(mPosition);
                    mPlayer.setDataSource(bean.getPath());
                    mPlayer.setOnCompletionListener(this);
                    mPlayer.prepare();
                    mPlayer.start();
                    if (null != onTrackListener) {
                        mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                onTrackListener.onPlayStateChange(false);
                                onTrackListener.onNext(bean);
                                onTrackListener.onPlayStateChange(true);
                            }
                        });

                    }

                } catch (IOException e) {
                    e.printStackTrace();
                    if (null != onTrackListener) {