<commit_before>package com.example.yangxp5.rebackandroid.service;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.os.Parcelable;

import com.example.yangxp5.rebackandroid.model.MusicInfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;

/**
 * Created by yangxp5 on 2015/12/14.
 */
public class MusicPlayerService extends Service {

    public static final String ARGS_MUSIC_LIST_KEY = "musicList";
    public static final String ARGS_MUSIC_CONTROL_KEY = "args_music_control_key";
    public static final String ARGS_MUSIC_CURRENT_POSITION_KEY = "current_position";
    public static final int FLAG_CONTROL_PLAY = 1;
    public static final int FLAG_CONTROL_PAUSE = 2;

    private Parcelable[] dataList;
    private int currentMusicPosition;
    private int currentPlayStatus = 0; //0:暂停 1：正在播放

    private static MediaPlayer mMediaPlayer;

    @Override
    public void onCreate() {
        super.onCreate();
        mMediaPlayer = new MediaPlayer();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        int flag = intent.getIntExtra(ARGS_MUSIC_CONTROL_KEY,FLAG_CONTROL_PLAY);
        switch (flag){
            case FLAG_CONTROL_PLAY :
                dataList = intent.getExtras().getParcelableArray(ARGS_MUSIC_LIST_KEY);
                currentMusicPosition = intent.getIntExtra(ARGS_MUSIC_CURRENT_POSITION_KEY,0);
                try {
                    MusicInfo musicInfo = (MusicInfo) dataList[currentMusicPosition];
                    try {
                        mMediaPlayer.setDataSource(musicInfo.getPath());
                        mMediaPlayer.prepareAsync();
                        mMediaPlayer.start();
                        currentPlayStatus = 1;
                    } catch (IOException e) {
                        e.printStackTrace();<commit_msg>本地音乐页面<commit_after>package com.example.yangxp5.rebackandroid.service;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.os.Parcelable;

import com.example.yangxp5.rebackandroid.model.MusicInfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;

/**
 * Created by yangxp5 on 2015/12/14.
 */
public class MusicPlayerService extends Service {

    public static final String ARGS_MUSIC_LIST_KEY = "musicList";
    public static final String ARGS_MUSIC_CONTROL_KEY = "args_music_control_key";
    public static final String ARGS_MUSIC_CURRENT_POSITION_KEY = "current_position";
    public static final int FLAG_CONTROL_PLAY = 1;
    public static final int FLAG_CONTROL_PAUSE = 2;

    private Parcelable[] dataList;
    private int currentMusicPosition;
    private int currentPlayStatus = 0; //0:暂停 1：正在播放

    private static MediaPlayer mMediaPlayer;

    @Override
    public void onCreate() {
        super.onCreate();
        mMediaPlayer = new MediaPlayer();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        int flag = intent.getIntExtra(ARGS_MUSIC_CONTROL_KEY,FLAG_CONTROL_PLAY);
        switch (flag){
            case FLAG_CONTROL_PLAY :
                dataList = intent.getExtras().getParcelableArray(ARGS_MUSIC_LIST_KEY);
                currentMusicPosition = intent.getIntExtra(ARGS_MUSIC_CURRENT_POSITION_KEY,0);
                try {
                    MusicInfo musicInfo = (MusicInfo) dataList[currentMusicPosition];
                    try {
                        System.out.println(musicInfo.getPath());
                        mMediaPlayer.setDataSource(musicInfo.getPath());
                        mMediaPlayer.prepareAsync();
                        mMediaPlayer.start();
                        currentPlayStatus = 1;
                    } catch (IOException e) {
                        e.printStackTrace();
{'fraction_non_alphanumeric': 0.07844129554655871, 'fraction_numerical': 0.009109311740890687, 'mean_word_length': 2.670380687093779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5632201', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1074, 'n_words': 238}