package com.androidmediaplayer.mp3player;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.SimpleAdapter;
import android.widget.SlidingDrawer;
import android.widget.TextView;
import android.widget.Toast;
import com.androidmediaplayer.R;
import com.androidmediaplayer.constant.AppConstant;
import com.androidmediaplayer.constant.ConstantExtendsApplication;
import com.androidmediaplayer.model.Mp3Info;
import com.androidmediaplayer.model.PlayList;
import com.androidmediaplayer.utils.InitPlayListThread;
import com.androidmediaplayer.utils.LinkedListPlayList;
import com.androidmediaplayer.utils.LrcProcessorUtils;
import com.androidmediaplayer.utils.PlayListMapUtil;
import com.androidmediaplayer.utils.PlayListUtil;
/**
* 顺序播放,最后一首了还按NEXT咋办
*
*/
public class MyPlayerActivity extends Activity {
private ImageButton modeButton_normal = null;
private ImageButton modeButton_repeat = null;
private ImageButton modeButton_repeat_single_ = null;
private ImageButton modeButton_shuffle = null;
// 避免500毫秒时间差产生 按住进度条拖拉过程中 被更新回原来的位置
private boolean canUpdate = true;
private SharedPreferences sp = null;
private ImageButton startAndPauseButton = null;
private ImageButton nextButton = null;
private ImageButton latestBtn = null;
private Mp3Info mp3Info = null;
private TextView artistView = null;
private TextView musicNameView = null;
private TextView lrcTextView = null;
private TextView positionView = null;
private TextView durationView = null;
private SeekBar seekBar = null;
private int currentProgress = 0;
private int duration = 0;
private UpdatePositionThread updatePositionThread = null;
private IntentFilter intentFilter = null;
private ServiceMSGReceiver receiver = null;
private UpdateLrcHandler updateLrcHandler = null;
// private UpdateLrcThread updateLrcThread = null;
private int point = 0;
private ArrayList<Long> times = null;
private int timesSize = 0;
private ArrayList<String> lrcs = null;
// private ArrayList<Long> timeToTime = null;
@SuppressWarnings("rawtypes")
private ArrayList<ArrayList> arrayList = null;
private Looper looper = null;
private ArrayList<Integer> playList_ids = null;
private ConstantExtendsApplication cea = null;
private boolean normalCompleteFlag = false;
private IMediaPlayerService mediaPlayerService = null;
private ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mediaPlayerService = IMediaPlayerService.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
mediaPlayerService = null;
}
};
// 更新UI(只运行一次)
private Handler updateUIHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
onLoad();
setPrepareUI();
updatePositionThread = new UpdatePositionThread();
updatePositionHandler.postDelayed(updatePositionThread, 500);
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mediaplayer_player_320_480);
cea = (ConstantExtendsApplication)getApplicationContext();
startAndPauseButton = (ImageButton) findViewById(R.id.playBtn);
startAndPauseButton.setOnClickListener(new StartButtonListener());
nextButton = (ImageButton) findViewById(R.id.nextBtn);
latestBtn = (ImageButton) findViewById(R.id.latestBtn);
lrcTextView = (TextView) findViewById(R.id.lrcText);
artistView = (TextView) findViewById(R.id.artistName);
musicNameView = (TextView) findViewById(R.id.songName);
seekBar = (SeekBar) findViewById(R.id.seekBar);
positionView = (TextView) findViewById(R.id.playTime);
durationView = (TextView) findViewById(R.id.duration);
setSeekBarListener();
receiver = new ServiceMSGReceiver();
registerReceiver(receiver, getIntentFilter());
looper = Looper.getMainLooper();
BindService();
mp3Info = (Mp3Info) getIntent().getSerializableExtra("mp3Info");
LinkedListPlayList.playListId = getIntent().getIntExtra("playListId", -1);
new Thread(new InitPlayListThread(this)).start();
// 进度条和歌词的更新
new Thread(new PrepareThread()).start();
setModeButtonListener();
setNLButtonListener();
}
@Override
protected void onResume() {
super.onResume();
cea.setPlayerActivityExist(true);
}
@Override
public void onBackPressed() {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
private class PrepareThread implements Runnable {
@Override
public void run() {
// updateLrcThread = new UpdateLrcThread();
updateLrcHandler = new UpdateLrcHandler(looper);
prepareLrc();
while (true) {
if (null != mediaPlayerService) {
break;
}
}
updateUIHandler.sendEmptyMessage(0);
}
}
// 绑定AIDL服务
private void BindService() {
Intent intent = new Intent(IMediaPlayerService.class.getName());
bindService(intent, connection, BIND_AUTO_CREATE);
}
// 点击歌曲时候
@SuppressWarnings({ "rawtypes", "unchecked" })
private void onLoad() {
canUpdate = true;
List list = new ArrayList();
list.add(mp3Info);
try {
mediaPlayerService.setFileInfo(list);
} catch (RemoteException e) {
e.printStackTrace();
}
}
// 播放和暂停按钮
private class StartButtonListener implements OnClickListener {
@Override
public void onClick(View v) {
try {
if (mediaPlayerService.isPlaying()) {
canUpdate = false;
mediaPlayerService.pause();
updatePositionHandler.removeCallbacks(updatePositionThread);
// updateLrcHandler.removeCallbacks(updateLrcThread);
startAndPauseButton.setImageResource(R.drawable.play_selector);
} else {
canUpdate = true;
mediaPlayerService.start();
updatePositionHandler
.postDelayed(updatePositionThread, 500);
// updateLrcHandler.post(updateLrcThread);
startAndPauseButton.setImageResource(R.drawable.pause_selector);
if (null != arrayList) {
lrcTextView.setText(lrcs.get(point));
}
//顺序播放模式,列表播放完毕,按下播放键后重头开始播放
if(sp.getInt("playMode", -1) == AppConstant.PlayMode.MODE_NOAMAL && normalCompleteFlag == true){
MyPlayerActivity.this.mp3Info = LinkedListPlayList.getFirst();
prepareLrc();
onLoad();
setPrepareUI();
updatePositionHandler.postDelayed(updatePositionThread, 500);
startAndPauseButton.setImageResource(R.drawable.pause_selector);
}
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
private void setNLButtonListener(){
nextButton.setOnClickListener(new OnClickListener() {
@Override
public voi
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Android 音乐播放器(晴天播放).zip项目安卓应用源码下载Android 音乐播放器(晴天播放).zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android 音乐播放器(晴天播放).zip项目安卓应用源码下载 (214个子文件)
IMediaPlayerService.aidl 399B
IMediaPlayerService.aidl 399B
resources.ap_ 159KB
mediaplayer2.apk 218KB
proguard.cfg 1KB
LocalMp3ListActivity.class 22KB
MyPlayerActivity.class 21KB
PlayListActivity.class 20KB
RemoteMp3ListActivity.class 20KB
MediaPlayerService.class 9KB
DownloadService.class 7KB
HttpDownloaderUtils.class 7KB
DownloadTaskThread.class 6KB
DownloadService$UpdateNotificationProgress.class 6KB
PlayListActivity$UpdatePlayListThread.class 5KB
RemoteMp3ListActivity$UpdateExListThread.class 5KB
FileUtil.class 5KB
MyPlayerActivity$ServiceMSGReceiver.class 5KB
IMediaPlayerService$Stub$Proxy.class 5KB
MainActivity.class 5KB
DownloadThread.class 5KB
IMediaPlayerService$Stub.class 4KB
InitPlayListThread.class 4KB
MyPlayerActivity$6.class 4KB
MediaPlayerService$1.class 4KB
PlayListUtil.class 4KB
RemoteMp3ListActivity$5.class 4KB
MyPlayerActivity$StartButtonListener.class 4KB
MediaPlayerService$4.class 3KB
Mp3Info.class 3KB
DataBaseOpenHelper.class 3KB
LrcProcessorUtils.class 3KB
MainActivity$Addshorcut.class 3KB
ScanService.class 3KB
RemoteMp3ListActivity$11.class 3KB
DownloadService$UpdateNotificationProgress$1.class 3KB
LocalMp3ListActivity$7.class 3KB
PlayListActivity$1.class 3KB
LocalMp3ListActivity$1.class 3KB
PlayListActivity$9.class 3KB
XML_Mp3ListContentHandler.class 3KB
LinkedListPlayList.class 3KB
ScanService$ScanSdReceiver.class 3KB
PlayListMapUtil.class 3KB
PlayListActivity$UpdatePlayListHandler.class 2KB
ConstantExtendsApplication.class 2KB
PlayListActivity$5.class 2KB
RemoteMp3ListActivity$UpdateHandler.class 2KB
MyPlayerActivity$7.class 2KB
DownloadTask.class 2KB
R$drawable.class 2KB
MyPlayerActivity$4.class 2KB
MyPlayerActivity$5.class 2KB
PlayListActivity$7.class 2KB
LocalMp3ListActivity$ScanSdReceiver.class 2KB
R$string.class 2KB
RemoteMp3ListActivity$9.class 2KB
MediaPlayerService$5.class 2KB
R$id.class 2KB
MyPlayerActivity$PrepareThread.class 2KB
RemoteMp3ListActivity$1.class 2KB
LocalMp3ListActivity$9.class 2KB
MyPlayerActivity$10.class 2KB
MyPlayerActivity$11.class 2KB
MyPlayerActivity$12.class 2KB
MyPlayerActivity$9.class 2KB
PlayListActivity$3.class 2KB
PlayListActivity$13.class 2KB
RemoteMp3ListActivity$6.class 2KB
LocalMp3ListActivity$4.class 2KB
PlayListActivity$10.class 2KB
LocalMp3ListActivity$3.class 2KB
RemoteMp3ListActivity$DownLoadMessageBroadcastReceiver.class 1KB
MyPlayerActivity$2.class 1KB
MyPlayerActivity$3.class 1KB
MyPlayerActivity$1.class 1KB
MyPlayerActivity$UpdateLrcHandler.class 1KB
MyPlayerActivity$UpdatePositionThread.class 1KB
DownloadService$DownloadLrcThread.class 1KB
RemoteMp3ListActivity$7.class 1KB
MediaPlayerService$6.class 1KB
PlayList.class 1KB
LocalMp3ListActivity$2.class 1KB
PlayListActivity$6.class 1KB
RemoteMp3ListActivity$10.class 1KB
RemoteMp3ListActivity$2.class 1KB
LocalMp3ListActivity$10.class 1KB
LocalMp3ListActivity$8.class 1KB
RemoteMp3ListActivity$12.class 1KB
PlayListActivity$4.class 1KB
PlayListActivity$2.class 1KB
RemoteMp3ListActivity$3.class 1016B
RemoteMp3ListActivity$8.class 1015B
PlayListActivity$8.class 1011B
LocalMp3ListActivity$5.class 1010B
PlayListActivity$11.class 989B
RemoteMp3ListActivity$4.class 984B
LocalMp3ListActivity$6.class 978B
StrTimeUtil.class 972B
PlayListActivity$14.class 966B
共 214 条
- 1
- 2
- 3
资源评论
yxkfw
- 粉丝: 76
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Python 程序语言设计模式思路-结构型模式:组合模式:将对象组合成树形结构
- 毕业设计基于python矩阵分解的推荐算法研究源码+详细文档+全部数据资料 高分项目.zip
- 基于网络的入侵检测系统源码+数据集+详细文档(高分毕业设计).zip
- 微信小程序源码 旅行故事分享 - 面包旅行App界面设计与文本展示资源下载
- 微信小程序源码 创意互动游戏 - 你画我猜App下载
- 摸底考试_学生版20230305.py
- 课程设计基于FPGA数字钟课程设计源码+课设报告(95分以上).zip
- 基于Java的企业家申报系统设计源码
- Cesium案例,集成各种模型,推演,各种Cesium效果
- 基于Python的Struts2全漏洞扫描利用工具设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功