![Delphi程序的設(shè)計及實驗指導(dǎo)第1章_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/7/3fbe4046-0f70-40f6-bc05-8dba23ed282c/3fbe4046-0f70-40f6-bc05-8dba23ed282c1.gif)
![Delphi程序的設(shè)計及實驗指導(dǎo)第1章_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/7/3fbe4046-0f70-40f6-bc05-8dba23ed282c/3fbe4046-0f70-40f6-bc05-8dba23ed282c2.gif)
![Delphi程序的設(shè)計及實驗指導(dǎo)第1章_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/7/3fbe4046-0f70-40f6-bc05-8dba23ed282c/3fbe4046-0f70-40f6-bc05-8dba23ed282c3.gif)
![Delphi程序的設(shè)計及實驗指導(dǎo)第1章_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/7/3fbe4046-0f70-40f6-bc05-8dba23ed282c/3fbe4046-0f70-40f6-bc05-8dba23ed282c4.gif)
![Delphi程序的設(shè)計及實驗指導(dǎo)第1章_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/7/3fbe4046-0f70-40f6-bc05-8dba23ed282c/3fbe4046-0f70-40f6-bc05-8dba23ed282c5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、第十一章第十一章 多媒體編程多媒體編程 11.1 動畫組件tanimate 11.2 簡單的動畫播放程序的設(shè)計 11.3 簡單的cd播放器的制作 1用途 2主要屬性 【例11-1】使用tanimate組件設(shè)計一個簡單的動畫播放程序。 11.1.2 媒體播放器組件tmediaplayer 2主要屬性 【例11-2】使用tmediaplayer組件編寫一個簡單的avi文件播放器程序。 為了更好地理解tanimate組件的屬性、方法和事件,這一節(jié)創(chuàng)建一個簡單的動畫播放程序。通過實例3,更好地掌握tanimate組件的應(yīng)用以及多媒體程序的設(shè)計思路。 11.2.1 界面設(shè)計 11.2.2 代碼編寫 1定
2、義存放起始幀、結(jié)束幀、循環(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è)置編輯框的數(shù)據(jù)合法性*) if (startframestopframe) or(stopframesumframe) then begin /輸入范圍錯誤 showmessage(輸入幀的范圍錯誤,所有設(shè)置復(fù)位!); 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 (*設(shè)置組件的enabled屬性*) play.enabled:=false; stop.enabled:=true; estartframe.enabled:=false; estopframe.enabled:=false; erepeatframe.enabled:=false; (*設(shè)置tanimate組件的屬性,然后進(jìn)行播放*) an
6、imate1.startframe:=startframe; animate1.stopframe:=stopframe; animate1.repetitions:=repeatframe; animate1.active:=true; /進(jìn)入播放狀態(tài) end; end; 4“停止播放”按鈕的onclick事件的處理程序代碼 procedure tform1.stopclick(sender: tobject); begin (*停止播放*) animate1.stop; play.enabled:=true; /“開始播放”按鈕可用 stop.enabled:=false; (*設(shè)置文本框
7、為可用*) estartframe.enabled:=true; estopframe.enabled:=true; erepeatframe.enabled:=true; end; 運(yùn)行程序,在estopframe文本框中輸入結(jié)束幀為9,單擊“開始播放”按鈕,結(jié)果如圖11-7所示。 圖11-7 運(yùn)行結(jié)果11.3 簡單的簡單的cd播放器的制作播放器的制作 11.3.1 界面設(shè)計 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、作用是為程序的運(yùn)行提供事件的控制,例如顯示cd播放的當(dāng)前位置、狀態(tài)等信息。這里利用memo組件顯示相關(guān)的信息。 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:=當(dāng)前狀態(tài): ;(*顯示cd播放的當(dāng)前狀態(tài)*) case mediaplayer1.mode of mpnotready: memo1.lines3:=str1+準(zhǔn)備未緒; 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)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- GB 45186-2024限制快遞過度包裝要求
- PB-22-7-Hydroxyquinoline-isomer-生命科學(xué)試劑-MCE-6693
- 9-Keto-tafluprost-生命科學(xué)試劑-MCE-9653
- 二零二五年度未簽勞動合同員工勞動仲裁應(yīng)對與勞動權(quán)益保障協(xié)議
- 2025年度文化創(chuàng)意產(chǎn)業(yè)計件工資與創(chuàng)意成果量化勞動合同
- 2025年度二零二五年度化妝品銷售提成獎勵合同
- 科技孵化器創(chuàng)新創(chuàng)業(yè)者的搖籃
- 跨學(xué)科視角下的小學(xué)生音樂素養(yǎng)培養(yǎng)研究
- 小學(xué)心理健康教育的實踐與思考
- 校園體育活動安全與防護(hù)措施
- 護(hù)理人文知識培訓(xùn)課件
- 建筑工程施工安全管理課件
- 2025年春新人教版數(shù)學(xué)七年級下冊教學(xué)課件 7.2.3 平行線的性質(zhì)(第1課時)
- 上海市楊浦區(qū)2022屆初三中考二模英語試卷+答案
- 高中英語原版小說整書閱讀指導(dǎo)《奇跡男孩》(wonder)-Part one 講義
- GB/T 4745-2012紡織品防水性能的檢測和評價沾水法
- 國家綜合性消防救援隊伍消防員管理規(guī)定
- 2023年全國各地高考英語試卷:完形填空匯編(9篇-含解析)
- 五年級上冊數(shù)學(xué)習(xí)題課件 簡便計算專項整理 蘇教版 共21張
- 疼痛科的建立和建設(shè)
- 運(yùn)動技能學(xué)習(xí)PPT課件
評論
0/150
提交評論