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
没有合适的资源?快使用搜索试试~ 我知道了~
小程序源码 影音播放 音乐播放器(晴天播放).rar
共211个文件
class:110个
png:42个
java:28个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2023-03-29
20:14:33
上传
评论
收藏 976KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序源码 影音播放 音乐播放器(晴天播放).rar (211个子文件)
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$11.class 2KB
MyPlayerActivity$10.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
共 211 条
- 1
- 2
- 3
资源评论
大富大贵7
- 粉丝: 317
- 资源: 8869
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 206693250008_R01C02_Grn.idat
- 瞳孔跟踪-基于OpenCV+网络摄像头的瞳孔跟踪算法实现-附项目源码+流程教程-优质项目分享.zip
- ModStartCMS v8.4.0 框架稳定性持续迭代,修复部分已知问题
- bleder 教室学校学生教育室办公室考试
- 人脸检测-使用OpenCV实现的动漫+漫画人脸检测算法-附项目源码-优质项目实战.zip
- 道路贴图,材质材料免费
- 人脸检测-基于OpenCV+Node.js+WebSockets实现的实时人脸检测应用-附项目源码-优质项目实战.zip
- 一些常见的MySQL死锁案例-mysql-deadlocks-master(源代码+案例+图解说明)
- UE4动画烘焙器-ue4.27
- 新建文件夹.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功