package cn.edu.xmu.software;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
import android.app.ListActivity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.view.Menu;
import android.view.View;
import android.view.Menu.Item;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import cn.edu.xmu.software.view.PathToNameAdapter;
/**
* this is a music player, default encoder is GB2312, can fetch the lyric
* from www.Baidu.com, find the proper cover for the album in the same
* directory
* @author Timlu 030lutian AT gmail DOT com
*@version 0.0.1 beta
*/
public class LastMusic extends ListActivity {
private Preferences mPreferences; //使用偏好,状态信息
private ProgressBar status_bar; //进度条
private ImageView mCover; //放置封面区
private ImageButton mPre, mPlay, mStop, mNext,
mPlayAllButton,mPlayListButton,mListAddButton,mListRemoveButton,
mOpenPlaylistButton,mSavePlaylistButton; //上下两排控制键
private TextView mTimepos = null; //已播放时间显示块
private Button mPlaymodView = null; //切换播放模式键
private boolean isPlaying = false; //播放状态
private boolean isPaused = false;
private IMediaPlayerController mpc = null; //后台播放器控制借口
private Preferences.PlayMod mPlayMod; //播放模式
private Preferences.PlayListMod mPlayListMod; //全部播放或选择播放
private int mPosition; //当前播放列表位置
private Handler mHandler = new Handler();
private UpdateStatus mus; //控制进度条更新线程
public static ArrayList<String> mDefaultPlayList = new ArrayList<String>();
public static String mPath; //当前播放歌曲路径
private String mCoverPath; //当前播放歌曲对应的封面路径
private MusicInfoDbAdapter mDbAdapter; //数据库控制接口
private String backgroud_playing_menuitem; //是否后台播放
private static final int SHOW_DETAIL = 0; //查看详情
private static final int OPEN_FILE = 1; //添加文件和目录
private static final int SAVE_PLAYLIST = 3; //存储播放列表
private static final int OPEN_PLAYLIST = 4; //打开播放列表
private static final int DETAIL_ID = Menu.FIRST;
private static final int SET_ID = Menu.FIRST + 1;
private static final int UPDATE_DATABASE = Menu.FIRST + 2;
private static final int SET_BACKGROUD_PLAYING=Menu.FIRST+3;
private static final int OPEN_FILE_CHOOSEN = Menu.FIRST+4;
/**
* create the MediaPlayer service controller.
*/
private ServiceConnection mConnection = new ServiceConnection(){
public void onServiceConnected(ComponentName className,
IBinder service){
mpc = IMediaPlayerController.Stub.asInterface(service);
Toast.makeText(LastMusic.this, R.string.detail_name, Toast.LENGTH_SHORT);
try {
mpc.registerCallback(pn);
} catch (DeadObjectException e) {
e.printStackTrace();
}
}
public void onServiceDisconnected(ComponentName className){
mpc = null;
try {
mpc.unregisterCallback(pn);
} catch (Exception e) {
e.printStackTrace();
}
}
};
/**
* this is used when the activity of "Detail" is shown, and the
* music is end , this call the detail to update its' content
*/
private IPlayNext pn = new IPlayNext.Stub(){
public void playNext(){
mCompleteHandler.sendEmptyMessage(0);
};
};
private Handler mCompleteHandler = new Handler(){
@Override public void handleMessage(Message msg){
playNext();
final int n = mCallbacks.beginBroadcast();
for( int i=0; i< n; i++){
try {
mCallbacks.getBroadcastItem(i).playNext();
} catch (DeadObjectException e) {
e.printStackTrace();
}
mCallbacks.finishBroadcast();
}
}
};
public static RemoteCallbackList<IPlayNext> mCallbacks =
new RemoteCallbackList<IPlayNext>();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.playlist);
mDbAdapter = new MusicInfoDbAdapter(this);
mDbAdapter.open();
bindService( new Intent(LastMusic.this,MusicPlayerService.class), //start service
mConnection,Context.BIND_AUTO_CREATE);
mPre = (ImageButton)findViewById(R.id.previous_button);
mPre.setOnClickListener( new OnClickListener(){
public void onClick(View v){
playPrevious();
}
});
mPlay = (ImageButton)findViewById(R.id.play_button);
mPlay.setOnClickListener( new OnClickListener(){
public void onClick(View v){
playButtonClick();
}
});
mStop = (ImageButton)findViewById(R.id.stop_button);
mStop.setOnClickListener( new OnClickListener(){
public void onClick(View v){
stopButtonClick();
}
});
mNext = (ImageButton)findViewById(R.id.next_button);
mNext.setOnClickListener( new OnClickListener(){
public void onClick(View v){
playNext();
}
});
mPlayAllButton = (ImageButton)findViewById(R.id.play_all_button);
mPlayAllButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
playAllClick();
}
});
mPlayListButton = (ImageButton)findViewById(R.id.play_list_button);
mPlayListButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
playListClick();
}
});
mListAddButton = (ImageButton)findViewById(R.id.list_add_button);
mListAddButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
listAddClick();
}
});
mListRemoveButton =(ImageButton)findViewById(R.id.list_remove_button);
mListRemoveButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
listRemoveClick();
}
});
mOpenPlaylistButton = (ImageButton)findViewById(R.id.open_playlist_button);
mOpenPlaylistButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
openPlaylistClick();
}
});
mSavePlaylistButton = (ImageButton)findViewById(R.id.save_playlist_button);
mSavePlaylistButton.setOnClickListener( new OnClickListener(){
public void onClick(View v){
savePlaylistClick();
}
});
status_bar = (ProgressBar)findViewById(R.id.status_bar);
mPreferences = new Preferences(this);
mPlayMod = mPreferences.getPlayMod();
mPosition = mPreferences.getSavedPostion();
mPlayListMod = mPreferences.getPlayListMod();
if(mPlayListMod.equals(Preferences.PlayListMod.PLAYALL)){
mListAddButton.setEnabled(false);
addAllFiles();
}
else{
mListAddButton.setEnabled(true);
addPlaylist(mPreferences.getDefaultPlaylistName());
}
fillPlaylist();
mPath = mDefaultPlayList.get(mPosition);
mPlaymodView = (Button)findViewById(R.id.playmod);
switch(mPlayMod){
case NORMAL:
mPlaymodView.setText(R.string.normal_mod);
break;
case REPEAT_THIS:
mPlaymodView.setText(R.string.repeat_this_mod);
break;
case REPEAT_ALL:
mPlaymodView.setText(R.string.repeat_all_mod);
break;
case RANDOM:
mPlaymo
没有合适的资源?快使用搜索试试~ 我知道了~
java mp3播放器
共145个文件
class:84个
java:20个
png:17个
5星 · 超过95%的资源 需积分: 10 163 下载量 135 浏览量
2008-09-03
16:25:35
上传
评论
收藏 609KB ZIP 举报
温馨提示
java mp3播放器 。
资源推荐
资源详情
资源评论
收起资源包目录
java mp3播放器 (145个子文件)
IMediaPlayerController.aidl 2KB
IMediaPlayerController.aidl 2KB
IPlayNext.aidl 74B
IPlayNext.aidl 74B
resources.ap_ 86KB
LastMusic.apk 183KB
LastMusic.class 20KB
Detail.class 10KB
Preferences.class 7KB
MusicInfoDbAdapter.class 4KB
Baidu.class 4KB
IMediaPlayerController$Stub$Proxy.class 4KB
Detail$UpdateLyric.class 3KB
IMediaPlayerController$Stub.class 3KB
FileChoose.class 3KB
PlaylistOpen.class 3KB
FileIconListAdapter.class 3KB
MusicPlayerService$1.class 3KB
PathToNameAdapter.class 3KB
R$id.class 3KB
SongInfo.class 2KB
Detail$UpdateStatus$1.class 2KB
MusicPlayerService.class 2KB
PlaylistSave.class 2KB
LastMusic$UpdateStatus$1.class 2KB
Detail$3.class 2KB
CoverDiscover.class 2KB
LastMusic$1.class 2KB
Configure.class 2KB
LyricBox.class 2KB
Detail$UpdateCover.class 2KB
Configure$1.class 1KB
IPlayNext$Stub.class 1KB
Detail$UpdateStatus.class 1KB
FileChoose$1.class 1KB
Detail$7.class 1KB
LyricSearch.class 1KB
R$drawable.class 1KB
R$string.class 1KB
Detail$6.class 1KB
Preferences$PlayMod.class 1KB
LastMusic$UpdateStatus.class 1KB
PlaylistOpen$3.class 1KB
Util.class 1KB
Detail$1.class 1KB
FileChoose$3.class 1KB
FileChoose$2.class 1KB
Preferences$PlayListMod.class 1KB
LastMusic$3.class 1KB
Preferences$PlayList.class 1KB
Detail$UpdateCover$1.class 1KB
PlaylistSave$1.class 1KB
LyricSearch$1.class 1KB
Detail$UpdateLyric$2.class 1KB
IPlayNext$Stub$Proxy.class 1KB
Configure$3.class 998B
Detail$UpdateLyric$1.class 989B
Detail$UpdateCover$2.class 952B
PlaylistOpen$1.class 948B
CoverDiscover$ImageFilter.class 942B
PlaylistSave$2.class 864B
MusicPlayerService$2.class 864B
PlaylistOpen$2.class 864B
LastMusic$15.class 858B
LyricSearch$2.class 858B
Detail$8.class 851B
Configure$2.class 830B
PlaylistOpen$4.class 828B
PlaylistSave$3.class 828B
IMediaPlayerController.class 828B
Detail$4.class 812B
LastMusic$5.class 795B
LastMusic$13.class 791B
LastMusic$12.class 791B
LastMusic$11.class 791B
LastMusic$14.class 791B
LastMusic$10.class 791B
LastMusic$6.class 789B
LastMusic$8.class 789B
LastMusic$9.class 789B
LastMusic$7.class 788B
LastMusic$4.class 788B
LastMusic$2.class 786B
Detail$5.class 774B
Detail$2.class 765B
R$layout.class 712B
R.class 587B
R$color.class 504B
R$attr.class 343B
IPlayNext.class 310B
.classpath 361B
classes.dex 281KB
nocover.gif 9KB
entagged-audioformats-0.15.jar 160KB
LastMusic.java 24KB
IMediaPlayerController.java 12KB
Detail.java 12KB
R.java 8KB
Preferences.java 5KB
MusicInfoDbAdapter.java 4KB
共 145 条
- 1
- 2
资源评论
- playrole2011-12-21很好的资源 但是要jmf包 配置有点麻烦
luckdog_hot
- 粉丝: 11
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功