




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、第十一章第十一章 多媒體編程多媒體編程 11.1 動(dòng)畫組件tanimate 11.2 簡單的動(dòng)畫播放程序的設(shè)計(jì) 11.3 簡單的cd播放器的制作 1用途 2主要屬性 【例11-1】使用tanimate組件設(shè)計(jì)一個(gè)簡單的動(dòng)畫播放程序。 11.1.2 媒體播放器組件tmediaplayer 2主要屬性 【例11-2】使用tmediaplayer組件編寫一個(gè)簡單的avi文件播放器程序。 為了更好地理解tanimate組件的屬性、方法和事件,這一節(jié)創(chuàng)建一個(gè)簡單的動(dòng)畫播放程序。通過實(shí)例3,更好地掌握tanimate組件的應(yīng)用以及多媒體程序的設(shè)計(jì)思路。 11.2.1 界面設(shè)計(jì) 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); (*驗(yàn)證動(dòng)畫屬性設(shè)置編輯框的數(shù)據(jù)合法性*) if (startframestopframe) or(stopframesumframe) then begin /輸入范圍錯(cuò)誤 showmessage(輸入幀的范圍錯(cuò)誤,所有設(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è)計(jì) 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)容里面會(huì)有圖紙預(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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 三年級上冊數(shù)學(xué)教案-7.4分?jǐn)?shù)的初步認(rèn)識(一)練習(xí)十一 |蘇教版
- 六年級上冊數(shù)學(xué)教案-6.1 比的認(rèn)識(一)|北師大版
- 加法運(yùn)算律教案2024-2025學(xué)年數(shù)學(xué)四年級上冊 西師大版
- 2025年轉(zhuǎn)讓有限公司股權(quán)合同
- 一致行動(dòng)人協(xié)議(2025年版)-@-1
- 一年級上冊數(shù)學(xué)教案-總復(fù)習(xí)第1課時(shí)數(shù)與代數(shù)(1)∣北師大版
- 河南省三門峽市陜州區(qū)三年級英語下學(xué)期期中試題(人教PEP版-含答案)
- 《秋詞》歷年中考古詩欣賞試題匯編(截至2022年)
- 2025年河南省信陽市單招職業(yè)適應(yīng)性測試題庫及答案1套
- 2025年湖南鐵路科技職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫參考答案
- 【道法】開學(xué)第一課 課件-2024-2025學(xué)年統(tǒng)編版道德與法治七年級下冊
- 中華民族共同體概論專家講座第一講中華民族共同體基礎(chǔ)理論
- 2023年浙江省統(tǒng)招專升本考試英語真題及答案解析
- GB 9706.202-2021醫(yī)用電氣設(shè)備第2-2部分:高頻手術(shù)設(shè)備及高頻附件的基本安全和基本性能專用要求
- 關(guān)于對項(xiàng)目管理的獎(jiǎng)懲制度
- A320主起落架收放原理分析及運(yùn)動(dòng)仿真
- 植筋施工方案(二標(biāo))
- 神經(jīng)外科疾病健康宣教
- 2. SHT 3543-2017施工過程文件表格
- 分部分項(xiàng)工程項(xiàng)目清單
- 電纜防火分析及措施
評論
0/150
提交評論