導航:首頁 > 操作系統 > android鋼琴源碼

android鋼琴源碼

發布時間:2022-08-24 22:52:45

❶ 基於android音樂播放器源代碼(正常播放、有列表)

package my.android.players;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;

public class mainActivity extends Activity {

private List<String> myMusicList=new ArrayList<String>();
//當前播放歌曲的索引
private int currentListItem=0;
//音樂的路徑
private static final String MUSIC_PATH="/sdcard/mp3";
//播放對象
private MediaPlayer myMediaPlayer;
private TextView m_TextView;
//播放按鈕
private ImageButton m_start;
private ImageButton m_stop;
private ImageButton m_next;
private ImageButton m_last;
/*設定bIsPaused一開始為false */
private boolean bIsRun = false;
private boolean isplay;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);

myMediaPlayer=new MediaPlayer();

musicList();
m_TextView=(TextView)findViewById(R.id.mtextview);
m_start=(ImageButton)findViewById(R.id.imgbtn_start);
m_stop=(ImageButton)findViewById(R.id.imgbtn_stop);
m_next=(ImageButton)findViewById(R.id.imgbtn_next);
m_last=(ImageButton)findViewById(R.id.imgbtn_last);
listener();

Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
currentListItem = bundle.getInt("currentListItem");
isplay=bundle.getBoolean("isplay");
if(isplay==true)
{
bIsRun=false;
playMusic(MUSIC_PATH+"/"+myMusicList.get(currentListItem));
}
}
//監聽事件
void listener(){

//開始
m_start.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try
{
if(myMediaPlayer.isPlaying()==true)
{
myMediaPlayer.pause();
m_start.setImageResource(R.drawable.pause);
}
else
{
playMusic(MUSIC_PATH+"/"+myMusicList.get(currentListItem));
}

}
catch (IllegalStateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

}
});
//下一首
m_next.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
nextMusic();
}
});

//上一首
m_last.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

lastMusic();
}
});

//停止
m_stop.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
stopMusic();
}
});

myMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
nextMusic();
}
});
}
//播放音樂
void playMusic(String path){
try {
if(bIsRun==false)
{
myMediaPlayer.reset();
myMediaPlayer.setDataSource(path);
myMediaPlayer.prepare();
myMediaPlayer.start();
/*
* 取出歌曲名的.mp3後綴
* */
String str=(myMusicList.get(currentListItem)).toString();
System.out.println(str);
String str1[]=str.split("\\.");
System.out.println(str1[0]);
m_TextView.setText(str1[0]);
}
else
{
myMediaPlayer.start();
}
m_start.setImageResource(R.drawable.start);
bIsRun=true;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}

//下一首
void nextMusic(){
if(++currentListItem>=myMusicList.size()){
currentListItem=0;
}
bIsRun=false;
playMusic(MUSIC_PATH+"/"+myMusicList.get(currentListItem));
}

//上一首
void lastMusic(){
if(--currentListItem<0)
currentListItem=myMusicList.size()-1;
bIsRun=false;
playMusic(MUSIC_PATH+"/"+myMusicList.get(currentListItem));
}
//停止
void stopMusic() {

if (myMediaPlayer.isPlaying()) {
m_start.setImageResource(R.drawable.pause);
myMediaPlayer.stop();// 停止
bIsRun=false;
}
else
playMusic(MUSIC_PATH+"/"+myMusicList.get(currentListItem));
}
//當用戶返回時結束音樂並釋放音樂對象
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode==KeyEvent.KEYCODE_BACK){
new AlertDialog.Builder(mainActivity.this).setTitle("message")
.setIcon(android.R.drawable.dialog_frame)
.setMessage("你確定要離開嗎?")
.setPositiveButton("確定",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
myMediaPlayer.stop();
myMediaPlayer.release();
finish();
}
}).setNegativeButton("取消",new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub

}
}).show();

}
return super.onKeyDown(keyCode, event);
}
/**
* 文件過濾器
*
* @author
*
*/
class MusicFilter implements FilenameFilter {

@Override
public boolean accept(File dir, String filename) {

return (filename.endsWith(".mp3"));
}

}
//綁定音樂
void musicList(){
try{
File home=new File(MUSIC_PATH);
if(!home.exists())
home.mkdirs();
if(home.listFiles(new MusicFilter()).length>=0){
for(File file:home.listFiles(new MusicFilter())){
myMusicList.add(file.getName().toString());
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

package my.android.players;

import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.AdapterView;
import android.widget.ArrayAdapter;

import android.widget.ListView;

public class Activity01 extends Activity {

//播放列表
private List<String> myMusicList=new ArrayList<String>();
//當前播放歌曲的索引
private int currentListItem;
//音樂的路徑
private static final String MUSIC_PATH="/sdcard/mp3";
//播放列表
private ListView m_ListView;

private boolean isplay=true;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

m_ListView=(ListView)findViewById(R.id.lv_music);

musicList();

//當選擇列表項時播放音樂
m_ListView.setOnItemClickListener(new ListView.OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
currentListItem = arg2;
Intent intent = new Intent();
Bundle mBundle=new Bundle();
mBundle.putInt("currentListItem", currentListItem);
mBundle.putBoolean("isplay", isplay);
intent.putExtras(mBundle);
intent.setClass(Activity01.this,mainActivity.class);
startActivity(intent);
finish();
}
});
}

/**
* 文件過濾器
*
* @author
*
*/
class MusicFilter implements FilenameFilter {

@Override
public boolean accept(File dir, String filename) {

return (filename.endsWith(".mp3"));
}

}

//綁定音樂
void musicList(){
try{
File home=new File(MUSIC_PATH);
if(!home.exists())
home.mkdirs();
if(home.listFiles(new MusicFilter()).length>=0){
for(File file:home.listFiles(new MusicFilter())){
myMusicList.add(file.getName().toString());
}
ArrayAdapter<String> musicList=new ArrayAdapter<String>
(Activity01.this,android.R.layout.simple_list_item_1, myMusicList);
m_ListView.setAdapter(musicList);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}

❷ 彈鋼琴 源碼

那個的flash地址是
http://flash.onlinedown.net/swf05/upflash/200606091122110.swf

❸ 如何獲取android源代碼

當前的Android代碼託管在兩個方:https://github.com/android 和https://android.googlesource.com之前在 android.git.kernel.org上也有託管,不過現在重定向到了https://android.googlesource.com好在都支持git訪問。

google提供的repo工具實際上是一個內部操作git工具來簡化操作Android源碼的Python腳本。經過嘗試,直接使用git工具在ubuntu下可以實現cloneAndroid源碼。下面介紹一下方法:

1.獲取當前的在github上託管的Androidgitrepositories:

github頁面為:https://github.com/android/following。不過這個頁面不支持通過wget"https://github.com/android/following"或者curl"https://github.com/android/following"的方式訪問,錯誤信息如下:

這個時候需能做的只能是"tryagain"了。

需要說明的是"不要試圖同時並發執行多個gitclone命令",這樣會導致大量出現上面貼圖中的錯誤,另外,整個clone過程中耗時最多的gitrepository如下:

kernel_common.gitkernel_msm.gitplatform_frameworks_base.gitplatform_prebuilt.git其中platform_prebuilt.git是google提供的預編譯好的二進制文件,包含:各種庫文件,jar包,可執行程序等等,如果只是閱讀Android源代碼,這個gitrepository可以不用clone.

❹ 怎樣查看 Android APP 源代碼

壓縮軟體打開apk文件,解壓出根目錄中的classes.dex文件

使用cmd ,dex2jar.bat classes.dex命令將classes.dex轉換為jar

再用jd-gui打開該jar就可以查看源碼了,如果apk安全性好的話,有些代碼是看不到的

❺ 誰有Android系統的源碼

1、通過 ubuntu 軟體中心安裝 wine;
2、通過 ubuntu 軟體中心安裝 winetricks;
3、通過 winetricks 在 shell中輸入: winetricks mfc42

1、通過 wine windows 的方式啟動代理伺服器
2、設置瀏覽器代理伺服器
3、設置shell代理伺服器:
在shell中輸入 sudo gedit /etc/bash.bashrc
在文件 /etc/bash.bashrc 中添加:如下內容
export http_proxy=http://127.0.0.1:8580/export https_proxy=http://127.0.0.1:8580/

通過shell安裝如下的組件:
1、sudo apt-get install bison g++-multilib git gperf libxml2-utils
2、新建一個存放源碼的目錄,如:mkdir ~/andorid/source
3、在源碼目錄中輸入命令:repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
其中: android-4.0.1_r1是android源碼的版本,更多的版本可以通過下面的方式查詢:http://source.android.com/source/build-numbers.html

4、修改source/.repo/manifest/default.xml 文件中的 fetch 的值為:
git://Android.git.linaro.org/

通過如下的指令來設置郵箱和用戶名
git config --global user.name "<your name>" ----修改用戶名git config --global user.email "<your email>" ----修改email

5、在source目錄下輸入指令:repo sync
便開始了代碼的下載

❻ Android是什麼語言編寫看懂源碼.它的開源代碼是什麼語言系統源碼來說

簡單來說 android 是以 linux kernel 內核為基礎的操作系統,你可以看看 linux kernel 是用什麼語言的就可以了。

❼ 求android源碼下載地址,就像學學源碼的原理

Google剛剛公布,穩定版的Android源代碼已經公布,任何人都可以免費下載。Google希望通過公布源代碼,電信運營商和手機製造商,乃至一般開發者們進一步深刻了解和利用Android系統,從而有益於該平台下的的發展。
看來T-Mobile G1不一定打得過iPhone,那麼Android呢?
現在源代碼公布在http://source.android.com/,SDK網站是http://code.google.com/android/

❽ 《Android開發範例代碼大全》源碼

這個怎麼可能有 除非買書附送的

❾ 為什麼android源碼還需要編譯

android源碼中有著許多的源代碼,其中有c和c++編寫的也有java編寫,這些代碼需要通過重新編譯後才能在android機器上運行的!當然你修改源碼,改完源碼後還是需要對源碼進行編譯的編譯的!android系統源碼的整體編譯需要很長時間,所以一般否是分開來編譯的!這樣縮短了編譯的等待時間,而且也實現了不同人對不同板塊代碼的修改和編譯的分工了!

❿ android源碼在哪個文件夾

android的源碼首先需要你從Android SDK Manager裡面下載,然後在你的sdk中才看得到。


閱讀全文

與android鋼琴源碼相關的資料

熱點內容
原耽小說下載 瀏覽:873
香港一級紅色電影 瀏覽:505
三級倫理電影胸大女主角拍的電影有哪些 瀏覽:170
但為君故by龍彌txt 瀏覽:384
mac安裝不了python庫 瀏覽:258
現代父子訓誡墨唯瑾 瀏覽:290
linux應用防火牆 瀏覽:500
百度雲伺服器白嫖 瀏覽:270
韓國同志電影肉多的有哪些 瀏覽:643
床戲很厲害的電影 瀏覽:893
蘇州追覓科技程序員 瀏覽:919
程序員我最多等你兩天 瀏覽:175
梁家輝電影在線觀看 瀏覽:277
好看的電影地址 瀏覽:838
福州愛琴海電影院 瀏覽:626
男主角是白頭發的日本電影 瀏覽:967
androidhtml滾動條 瀏覽:679
在線電影網站推薦 知乎 瀏覽:383
python多長時間能學習 瀏覽:884
java正則圖片 瀏覽:601