freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

ophone手機(jī)音樂功能實(shí)現(xiàn)研究(doc畢業(yè)設(shè)計(jì)論文)(編輯修改稿)

2025-07-25 08:34 本頁面
 

【文章內(nèi)容簡介】 表中刪除相應(yīng)歌曲信息,同時(shí)默認(rèn)歌曲指向下一首歌曲。播放器的狀態(tài)有播放、暫停、停止三種。: 播放器的狀態(tài)圖: 播放文件的狀態(tài)圖由上圖可以看出,當(dāng)用戶需要播放文件時(shí),點(diǎn)擊播放或者雙擊播放文件時(shí),則產(chǎn)生一個(gè)事件,調(diào)用Play函數(shù)完成播放。播放某一音樂文件的時(shí)候,播放器可能出于不同的狀態(tài),對于不同的狀態(tài),音樂系統(tǒng)運(yùn)行流程是不一樣的。: 播放歌曲的活動圖二、 Ophone音樂功能的詳細(xì)設(shè)計(jì)Ophone音樂功能開發(fā)的時(shí)候分為幾個(gè)部分,分別為src、gen和res文件夾。而src內(nèi)部主要是java的源程序代碼,主要是實(shí)現(xiàn)音樂功能的函數(shù)模塊。gen內(nèi)部主要包含的是是一個(gè)R類,主要包含的是各個(gè)部分的在這里的申明,這個(gè)文件夾里面的內(nèi)容無需編寫,只要其他部分編寫,其內(nèi)部會自動生成相應(yīng)的內(nèi)容。顯示在模擬器上面的畫面內(nèi)容的主要是在res文件夾中的,這個(gè)文件夾又分為3個(gè)部分,分別為draw、layout和values部分,drawable中存儲的是模擬器中出現(xiàn)的圖片,其他兩個(gè)文件夾是編寫的xml程序的,主要是在模擬器上顯示相應(yīng)的內(nèi)容。OPhone系統(tǒng)提供了MediaScanner,MediaProvider,MediaStore等接口,并且提供了一套數(shù)據(jù)庫表格,通過Content Provider的方式提供給用戶。當(dāng)手機(jī)開機(jī)或者有SD卡插拔等事件發(fā)生時(shí),系統(tǒng)將會自動掃描SD卡和手機(jī)內(nèi)存上的媒體文件,將相應(yīng)的信息放到定義好的數(shù)據(jù)庫表格中。在這個(gè)程序中,我們不需要關(guān)心如何去掃描手機(jī)中的文件,只要了解如何查詢和使用這些信息就可以了。MediaStore中定義了一系列的數(shù)據(jù)表格,通過ContentResolver提供的查詢接口,我們可以得到各種需要的信息音樂文件的播放功能是由MediaPlayer類實(shí)現(xiàn)的,MediaPlayer提供了常用的接口,比如播放,暫停,停止等。:現(xiàn)在可以開始動手構(gòu)建簡單的播放器示例程序。創(chuàng)建工程在Eclipse開發(fā)環(huán)境中創(chuàng)建一個(gè)新的Android Project.File New Android Project.設(shè)置工程名為MusicPlayerDemo, 設(shè)置packages名為  指定程序的Application,添加MusicPlayerDemoApp usicPlayerDemoApp類,它繼承自 。Application類用來存儲程序的狀態(tài),它存在于整個(gè)程序的生命周期之中。,指定MusicPlayerDemoApp為示例程序的Application. 這里需要注意Application的兩個(gè)函數(shù): onCreate() 和 onTerminate(). 當(dāng)程序開始運(yùn)行時(shí),onCreate()函數(shù)會首先被調(diào)用,此時(shí)沒有任何其他的對象在運(yùn)行,在這里我們可以進(jìn)行一些初始化的工作。當(dāng)程序結(jié)束時(shí), onTerminate()函數(shù)會被調(diào)用,程序進(jìn)程將會退出,可以在此做一些最終的清理工作。需要注意的是,當(dāng)因?yàn)橄到y(tǒng)資源緊張等問題,程序被系統(tǒng)kill的時(shí)候,onTerminate()不會被調(diào)用到,程序?qū)⒅苯油顺?。管理音樂信息的類MusicDBController為了使接口整潔,便于管理和使用,管理音樂信息的方法統(tǒng)一封裝在MusicDBController類中。 MusicDBController采用單例模式,使程序中只有唯一的實(shí)例。我們傳入MusicPlayerDemoApp 作為Context生成Content Resolver,用來查詢媒體庫。現(xiàn)在,修改MusicPlayerDemoApp,添加一個(gè)MusicDBController的成員,并在onCreate()中初始化它。private MusicDBController mDBContorller = null。 public void onCreate() { // TODO Autogenerated method stub ()。 // init MusicDBController mDBContorller = (this)。 } 并且提供一個(gè)獲取MusicDBController的接口: public MusicDBController getMusicDBController(){ return mDBContorller。這樣程序中的任何Activity和Serivce都可以通過getApplicatio()函數(shù)得到MusicPlayerDemoApp,再通過getMusicDBController()接口獲取MusicDBController,進(jìn)而獲取所需要的媒體信息。展示媒體庫-MusicListActivity 和 MusicListAdapter。首先添加MusicListAdapter,它繼承自SimpleCursorAdapter。通過重載bindView()函數(shù), 把媒體庫信息綁定到指定的ListView上。,它的布局定義如下:: 圖片 左上文字 左下文字 右下文字public void bindView(View view, Context context, Cursor cursor) { (view, context, cursor)。 TextView titleView = (TextView) ()。 TextView artistView = (TextView) ()。 TextView durationView = (TextView) ()。 ImageView imageView = (ImageView) ()。 // Set icon ()。 // Set track name ((()))。 // Set artist name ((()))。 // Set duration int duration = (())。 (makeTimeString(duration))。 }現(xiàn)在可以來添加我們的第一個(gè)Activity -MusicListActivity,它以List的形式展示了所有歌曲。MusicListActivity繼承自ListActivity。在onCreate()中獲取MusicDBController的實(shí)例,為獲取歌曲信息做準(zhǔn)備。播放-使用Service現(xiàn)在需要考慮如何來播放這些媒體庫中的文件了。為了達(dá)到后臺播放的效果,需要使用Service。當(dāng)程序的所有Activity都退出后,Service仍然可以在后臺運(yùn)行。在這個(gè)示例中我們使用Local Service,它與應(yīng)用程序運(yùn)行在同一個(gè)進(jìn)程中。首先,創(chuàng)建一個(gè)MusicPlaybackService類,重載onBind方法,返回自定義的LocalBinder,通過LocalBinder的getService()方法就可以獲得MusicPlaybackService的句柄了。privatefinalIBindermBinder=newLocalBinder()。publicclassLocalBinderextendsBinder{publicMusicPlaybackServicegetService(){return}}@OverridepublicIBinderonBind(Intentintent){//TODOAutogeneratedmethodstubreturnmBinder。}繼續(xù)完成MusicPlaybackService的基本構(gòu)架,添加一個(gè)MediaPlayer成員,并在onCreate()函數(shù)中對其進(jìn)行初始化,它將負(fù)責(zé)音樂播放的主要功能。privateMediaPlayermMediaPlayer=null。publicvoidonCreate(){()。mMediaPlayer=newMediaPlayer()。}  構(gòu)架完成MusicPlaybackService的基本架構(gòu)后,我們要定義一些常用的控制接口了,其他模塊通過這些接口,可以控制音樂的播放,暫停,停止等功能。1. publicvoidsetDataSource(Stringpath){try{()。(path)。()。}catch(IOExceptione){return。}catch(IllegalArgumentExceptione){return。}}publicvoidstart(){()。}publicvoidstop(){()。}publicvoidpause(){()。}publicbooleanisPlaying(){return()。}publicintgetDuration(){return()。}publicintgetPosition(){return()。}publiclongseek(longwhereto){((int)whereto)。returnwhereto。}最后,,添加MusicPlaybackService的定義。serviceandroid:name=.MusicPlaybackServiceandroid:exported=trueintentfilteractionandroid:name=//intentfilter/serviceservice android:name=.MusicPlaybackService android:exported=true intentfilter action android:name= / /intentfilter /service6播放歌曲MusicPlaybackService準(zhǔn)備就緒,我們可以利用它來播放歌曲了。修改MusicListActivity,在 onCreate() 中通過startService()函數(shù)啟動MusicPlaybackService,并通過bindService()函數(shù)與之綁定。當(dāng)綁定完成時(shí),ServiceConnection的 onServiceConnected()接口將被調(diào)用。privateMusicPlaybackServicemPlaybackService=null。privateServiceConnectionmPlaybackConnection=newServiceConnection(){publicvoidonServiceConnected(ComponentNameclassName,IBinderservice){mPlaybackService=(()service).getService()。}publicvoidonServiceDisconnected(ComponentNameclassName){mPlaybackService=null。}}。publicvoidonCreate(BundlesavedInstanceState){(savedInstanceState)。setContentView()。mDBController=((MusicPlayerDemoApp)getApplication()).getMusicDBController()。//bindplaybackservicestartService(newIntent(this,))。bindService(newIntent(this,),mPlaybackConnection,)。為MusicListActivity添加點(diǎn)擊事件處理,當(dāng)用戶點(diǎn)擊一個(gè)音樂item時(shí),會開始自動播放該歌曲,當(dāng)用戶點(diǎn)擊一個(gè)item時(shí),onListItemClick()函數(shù)會被調(diào)用。protectedvoidonListItemClick(ListViewl,Viewv,intposition,longid){//TODOAutogeneratedmethodstub(l,v,position,id)。if(mCursor==null||()==0){return。}(position)。Stringurl=mCursor.getString(mCursor.getColumnIndexOrThrow())。(url)。()。}控制-使用Intent和Broadcast Receiver目前我們只能播放音樂,還無法控制音樂的播放,暫停,停止。我們進(jìn)一步來完善這個(gè)播放程序,給它添加兩個(gè)控制按鈕。?xml version= encoding=UTF8? LinearLayout android:id=@+id/widget1 android:layout_width=fill_parent android:layout_height=fill_parent xmlns:android= android:orientation=vertical RelativeLayout android:id=@+id/control_panel android:orientation=horizontal android:layout_width=fill_parent android:layout_height=wrap_content TextView android:id=@+id/show_text a
點(diǎn)擊復(fù)制文檔內(nèi)容
電大資料相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1