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

正文內(nèi)容

基于android系統(tǒng)的音樂播放器設(shè)計(jì)與實(shí)現(xiàn)-在線瀏覽

2025-03-07 14:54本頁面
  

【正文】 sion: Indigo Service Release 1 ADT Version: 運(yùn)行環(huán)境:Android 第五章 音樂播放器詳細(xì)設(shè)計(jì)與實(shí)現(xiàn)首先是創(chuàng)建一個主界面MainActivity,它使用TabHost布局,這里面的TabWidget控件控制著兩個Activity的互相切換:一個是Mp3PlayerListActivity(圖51),這個Activity是一打開程序就顯示的服務(wù)器歌曲列表。圖52 LocalActivity在LocalActivity中點(diǎn)擊列表中的歌曲名就會調(diào)出PlayerActivity(圖53),這個Activity就是播放音樂時(shí)的界面,其中有一些對播放器進(jìn)行控制的控件。因?yàn)榇蜷_播放器首先就要刷新服務(wù)器上的歌曲列表,那么我們就得獲取服務(wù)器上的歌曲列表文件,即XML文件。 String line = null。 try { // 創(chuàng)建一個URL對象 URL url = new URL(urlStr)。 // 使用io讀取數(shù)據(jù) buffer = new BufferedReader(new InputStreamReader( ()))。 } } catch (Exception e) { ()。 } catch (Exception e2) { ()。 }從服務(wù)器上下載到XML中的文本后就要開始解析,在開始解析之前我們先來了解一下服務(wù)器上用來保存歌曲信息的XML文件。在我所設(shè)計(jì)的播放器中所用到是實(shí)現(xiàn)SAX(Simple API for XML)接口的方式來解析XML文件,解析的實(shí)現(xiàn)代碼如下: //開始解析XML文件中的每一個標(biāo)簽時(shí)調(diào)用的方法 Override public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException { //將從XML文件中讀取到的標(biāo)簽名賦值給tagName tagName = localName。 } } //解析完XML文件中的每一個標(biāo)簽時(shí)調(diào)用的方法 Override public void endElement(String uri, String localName, String qName) throws SAXException { //每次讀取到resource標(biāo)簽就代表一首歌曲的信息已經(jīng)完成,并將次mp3Info加到infos當(dāng)中 if ((resource)) { (mp3Info)。 } //讀取XML文件中沒一個標(biāo)簽中內(nèi)容 Override public void characters(char[] ch, int start, int length) throws SAXException { //將讀取到的內(nèi)容賦值給temp String temp = new String(ch, start, length)。 } else if (()) { (temp)。 } else if (()) { (temp)。 } }根據(jù)URL的地址從服務(wù)器上下載文件,因?yàn)橄螺d不可能是一瞬間就能完成的事,如果我們在主線程中進(jìn)行下載,那么下載過程中程序就會出現(xiàn)假死狀態(tài),因?yàn)樗诘却募螺d完成,下載完成才能執(zhí)行后面的操作,所以我們需要用一個線程來進(jìn)行下載任務(wù),實(shí)現(xiàn)代碼如下:// 每次用戶點(diǎn)擊ListActivity當(dāng)中的一個條目時(shí),就會調(diào)用該方法 Override public int onStartCommand(Intent intent, int flags, int startId) { // 從Intent對象當(dāng)中將Mp3Info對象取出 Mp3Info mp3Info = (Mp3Info) (mp3Info)。 // 啟動新線程 Thread thread = new Thread(downloadThread)。 return (intent, flags, startId)。 public DownloadThread(Mp3Info mp3Info) { = mp3Info。 // 生成下載對象所用的對象 HttpDownloader Downloader = new HttpDownloader()。 String resultMessage = null。 //(getApplicationContext(), resultMessage, ).show()。 } else if (result == 1) { resultMessage = 文件已存在。 //(this, resultMessage, ).show()。 (resultMessage)。讀取MP3文件的路徑,實(shí)現(xiàn)代碼如下://獲取mp3文件的路徑 private String getMp3Path(Mp3Info mp3Info) { //先獲得SDCard路徑 String SDCardRoot = () .getAbsolutePath()。 return path。 setContentView()。 mp3Info = (Mp3Info) (mp3Info)。 pauseButton = (ImageButton) findViewById()。 textView = (TextView) findViewById()。 (new BeginButtonListener())。 (new StopButtonListener())。 mediaPlayer = (, (file:// + path))。 ()。 isReleased = false。 isPause = true。 isPause = false。 ()。 } isPlaying = false。 第六章 結(jié) 論1. 通過對Android手機(jī)平臺的音樂播放器的開發(fā),使我對Android系統(tǒng)從零進(jìn)入到了一個比較高的層次的了解,Android功能是如此強(qiáng)大,令人不得不佩服。2. 在最初設(shè)計(jì)的界面的時(shí)候,總是不如意,糾結(jié)了好久,后來在網(wǎng)上找了許多資料,最后才決定了在主界面使用TabHost這種布局來進(jìn)行服務(wù)器列表與本地列表的切換。4. 在進(jìn)行聯(lián)網(wǎng)下載歌曲信息的時(shí)候總是失敗,再三確認(rèn)代碼后,確定無誤,可還是下載失敗,后來經(jīng)老師指導(dǎo),才發(fā)現(xiàn),原來Android中的軟件聯(lián)網(wǎng)是需要權(quán)限的,同時(shí)我還順便了解到了,讀寫SDCard也是需要權(quán)限的。6. 因?yàn)闀r(shí)間有限,播放器尚不夠完善,有些地方還有些不合理的地方,比如時(shí)間進(jìn)度條和歌詞的同步顯示,還有播放器只能播放MP3格式的用音樂,界面還不太友好等等,這些都有待以后去加強(qiáng)。這里有治學(xué)嚴(yán)謹(jǐn)而又親切的老師,有互相幫助的同學(xué),更有積極、向上、融洽的學(xué)習(xí)生活氛圍。不僅學(xué)到就更多的理論知識,擴(kuò)展了知識面,提高了自己的實(shí)際操作能力;而且學(xué)會了如何去學(xué)習(xí)新的知識,學(xué)會了面對困難和挑戰(zhàn),學(xué)會了團(tuán)結(jié)合作,互助互利。首先感謝指導(dǎo)老師。在此,我對他們的耐心指導(dǎo)和幫助表達(dá)我最真誠的謝意,感謝他們在這幾個月來所付出的努力。此外,他們的嚴(yán)謹(jǐn)治學(xué)態(tài)度和忘我的工作精神值得我去學(xué)習(xí)。非常感謝我的同學(xué)。同時(shí),感謝四年來傳授我知識的老師們,更要感謝我的家人及朋友對我學(xué)業(yè)上的支持和鼓勵,感謝所有關(guān)心、幫助過我的人。我不會忘記你們。 參考文獻(xiàn)[1] 韓超,梁泉 著,Android系統(tǒng)原理及開發(fā)要點(diǎn)詳解,[2] 李寧,Android/OPhone 開發(fā)完全講義,中國水利水電出版社,[3] (美)??藸?著 陳昊鵬 譯,Java編程思想(第4版),機(jī)械工業(yè)出版社, [4] E2EColud工作室,深入淺出GoogleAndroid,人民郵電出版社,[5] 余志龍,王世江 改編,GoogleAndroidSDK開發(fā)范例大全,人民郵電出版社,[6] 毛應(yīng)爽,趙慧玲,孟憲穎,sql server 2005數(shù)據(jù)庫程序設(shè)計(jì),清華大學(xué)出版社,[7] 龍馬工作室,新編Photoshop CS4中文版從入門到精通,人民郵電出版社,[8] 孫衛(wèi)琴,Tomcat與Java Web開發(fā)技術(shù)詳解(第2版),電子工業(yè)出版社 附 錄主界面MainActivity布局文件代碼:TabHost xmlns:android= android:id=android:id/tabhost android:layout_width=fill_parent android:layout_height=fill_parent android:background=drawable/bg1 LinearLayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent android:padding=5dp TabWidget android:id=android:id/tabs android:layout_width=fill_parent android:layout_height=wrap_content / FrameLayout android:id=android:id/tabcontent android:layout_width=fill_parent android:layout_height=fill_parent android:padding=5dp / /LinearLayout服務(wù)器列表界面Mp3PlayerListActivity布局文件代碼:?xml version= encoding=utf8?LinearLayout xmlns:android= android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical LinearLayout android:id=+id/listLinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical ListView android:id=id/android:list android:layout_width=fill_parent android:layout_height=wrap_content android:drawSelectorOnTop=false android:scrollbars=vertical / /LinearLayout/LinearLayout本地歌曲列表界面LocalActivity布局文件代碼:?xml version= encoding=utf8?LinearLayout xmlns:android= android:layout_width=fill_parent android:layout_height=fill_parent android:orientation=vertical LinearLayout android:id=+id/listLinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertic
點(diǎn)擊復(fù)制文檔內(nèi)容
范文總結(jié)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1