




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、第十一章第十一章 多媒體編程多媒體編程 11.1 動畫組件tanimate 11.2 簡單的動畫播放程序的設計 11.3 簡單的cd播放器的制作 1用途 2主要屬性 【例11-1】使用tanimate組件設計一個簡單的動畫播放程序。 11.1.2 媒體播放器組件tmediaplayer 2主要屬性 【例11-2】使用tmediaplayer組件編寫一個簡單的avi文件播放器程序。 為了更好地理解tanimate組件的屬性、方法和事件,這一節(jié)創(chuàng)建一個簡單的動畫播放程序。通過實例3,更好地掌握tanimate組件的應用以及多媒體程序的設計思路。 11.2.1 界面設計 11.2.2 代碼編寫 1定
2、義存放起始幀、結束幀、循環(huán)次數(shù)和總幀數(shù) var form1: tform1; startframe,stopframe,repeatframe,sumframe:integer; 2tanimate1組件的onopen事件處理程序代碼 procedure tform1.animate1open(sender: tobject); begin showmessage(tanimaet組件觸發(fā)onopen事件,初始化變量!); (*初始化變量*) startframe:=animate1.startframe; stopframe:=animate1.stopframe; repeatframe:
3、=animate1.repetitions; sumframe:=animate1.framecount; estartframe.text:=inttostr(startframe); estopframe.text:=inttostr(stopframe); esumframe.text:=inttostr(sumframe); erepeatframe.text:=inttostr(repeatframe); end; 3“開始播放”按鈕的onclick事件處理程序代碼 procedure tform1.playclick(sender: tobject); begin startfra
4、me:=strtoint(estartframe.text); stopframe:=strtoint(estopframe.text); repeatframe:=strtoint(erepeatframe.text); (*驗證動畫屬性設置編輯框的數(shù)據(jù)合法性*) if (startframestopframe) or(stopframesumframe) then begin /輸入范圍錯誤 showmessage(輸入幀的范圍錯誤,所有設置復位!); animate1.startframe:=1; animate1.stopframe:=animate1.framecount; anim
5、ate1.repetitions:=0; estartframe.text:=1; estopframe.text:=inttostr(animate1.framecount); erepeatframe.text:=0; end else begin (*設置組件的enabled屬性*) play.enabled:=false; stop.enabled:=true; estartframe.enabled:=false; estopframe.enabled:=false; erepeatframe.enabled:=false; (*設置tanimate組件的屬性,然后進行播放*) an
6、imate1.startframe:=startframe; animate1.stopframe:=stopframe; animate1.repetitions:=repeatframe; animate1.active:=true; /進入播放狀態(tài) end; end; 4“停止播放”按鈕的onclick事件的處理程序代碼 procedure tform1.stopclick(sender: tobject); begin (*停止播放*) animate1.stop; play.enabled:=true; /“開始播放”按鈕可用 stop.enabled:=false; (*設置文本框
7、為可用*) estartframe.enabled:=true; estopframe.enabled:=true; erepeatframe.enabled:=true; end; 運行程序,在estopframe文本框中輸入結束幀為9,單擊“開始播放”按鈕,結果如圖11-7所示。 圖11-7 運行結果11.3 簡單的簡單的cd播放器的制作播放器的制作 11.3.1 界面設計 11.3 簡單的簡單的cd播放器的制作播放器的制作圖11-8 cd播放器的界面11.3 簡單的簡單的cd播放器的制作播放器的制作 11.3.2 代碼編寫11.3 簡單的簡單的cd播放器的制作播放器的制作 2按鈕的onc
8、lick事件處理程序代碼 procedure tform1.button1click(sender: tobject); begin mediaplayer1.play; /“播放”按鈕的onclick事件處理 end; procedure tform1.button3click(sender: tobject); begin mediaplayer1.pause; /“暫?!卑粹o的onclick事件處理 end;11.3 簡單的簡單的cd播放器的制作播放器的制作procedure tform1.button2click(sender: tobject);beginmediaplayer1.s
9、top;滯不前 /“停止”按鈕的onclick事件處理end;procedure tform1.button4click(sender: tobject);beginmediaplayer1.previous; /“前一曲”按鈕的onclick事件處理end;procedure tform1.button6click(sender: tobject);beginmediaplayer1.next; /“后一曲”按鈕的onclick事件處理end;procedure tform1.button7click(sender: tobject);beginmediaplayer1.eject;勤部 /
10、“彈出”按鈕的onclick事件處理end;11.3 簡單的簡單的cd播放器的制作播放器的制作 (*“打開”按鈕的onclick事件處理*) procedure tform1.button5click(sender: tobject); begin if opendialog1.execute then begin mediaplayer1.filename:=opendialog1.filename; mediaplayer1.open; end; end;11.3 簡單的簡單的cd播放器的制作播放器的制作 3timer1組件的timer1timer事件處理程序代碼 窗體中的timer組件的
11、作用是為程序的運行提供事件的控制,例如顯示cd播放的當前位置、狀態(tài)等信息。這里利用memo組件顯示相關的信息。 procedure tform1.timer1timer(sender: tobject); var i,j,k:integer; pos1,pos2:longint; flag:boolean; str1:string;11.3 簡單的簡單的cd播放器的制作播放器的制作 begin memo1.lines0:=總曲目數(shù):+inttostr(mediaplayer1.tracks); mediaplayer1.timeformat:=tfmilliseconds; pos1:=0;
12、pos2:=0; flag:=true; for i:=0 to mediaplayer1.tracks-1 do /顯示正在播放的第幾首曲目 begin for j:=0 to i-1 do begin pos1:=pos1+mediaplayer1.tracklengthj; pos2:=pos1; end;11.3 簡單的簡單的cd播放器的制作播放器的制作 pos2:=pos2+mediaplayer1.tracklengthi; if mediaplayer1.positionpos1 then begin if mediaplayer1.positionpos2 then begin
13、 memo1.lines1:=正在播放的曲目:第 +inttostr(i+1)+ 首; flag:=false; end; end; end; 11.3 簡單的簡單的cd播放器的制作播放器的制作if flag then memo1.lines1:=正在播放的曲目:第 1 首; k:=round(mediaplayer1.length/60000); memo1.lines2:=曲目長度:+inttostr(k); str1:=當前狀態(tài): ;(*顯示cd播放的當前狀態(tài)*) case mediaplayer1.mode of mpnotready: memo1.lines3:=str1+準備未緒; mpstopped: memo1.lines3:=str1+已停止; mpplaying: memo1.lines3:=str1+正在播放; mprecording: memo1.lines3:=str1+正在記錄; mpseeking: memo1.lines3
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 王夫之與譚嗣同認識論比較研究
- 基于細粒含量和塑性指數(shù)的砂黏混合物小應變動力特性研究
- 社區(qū)消防知識教育
- 護理實習生疑難病例報告撰寫指南
- 盧梭公民教育理論
- 營養(yǎng)健康知識講座
- 車輛落戶流程
- 領獎禮儀班會課課件
- 《智能網(wǎng)聯(lián)整車綜合測試》課件-交叉路口通行場景測試評價
- 預防近視知識課件圖片
- 后進生轉化情況記錄表2
- 國際節(jié)能效果測量和驗證規(guī)程
- 可感染人類的高致病性病原微生物菌(毒)種或樣本運輸管理規(guī)定
- DL∕T 2055-2019 輸電線路鋼結構腐蝕安全評估導則
- AUMA澳瑪執(zhí)行器內部培訓課件
- 灌陽地質概況學習教案
- 門式腳手架專項施工方案完成
- 《全家便利店》第二課
- 黃土高原典型生態(tài)區(qū)基礎數(shù)據(jù)庫技術規(guī)范
- 第2章中子活化分析
- 武漢市市級預算單位銀行賬戶和資金管理暫行辦法
評論
0/150
提交評論