お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"マルチメディアの連続再生"

この発言に対し以下のコメントが寄せられています
#01215 TN さん RE:マルチメディアの連続再生

 CD-RWドライブを買うと,音楽などを WAVE ファイル に保存できるソフトが おまけでついてきますが,OS付属のメディアプレイヤでは連続再生できなかった ので,フォルダの中のファイルを順番に再生するものを作りました. mpegも再生可.こういのってどこかにありそうですが(^^; (めんどうなのはNotifyイベントの取り扱いか..) ------------------------------------------------------------------ unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, IniFiles, ExtCtrls, ComCtrls, StdCtrls, FileCtrl, MPlayer; type TForm1 = class(TForm) Panel1: TPanel; Panel2: TPanel; DriveComboBox1: TDriveComboBox; FileListBox1: TFileListBox; DirectoryListBox1: TDirectoryListBox; Splitter1: TSplitter; FilterComboBox1: TFilterComboBox; Button1: TButton; Button3: TButton; Button4: TButton; Button5: TButton; MP1: TMediaPlayer; Label1: TLabel; Label3: TLabel; Panel3: TPanel; procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure MP1Notify(Sender: TObject); procedure Button4Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Button5Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Private 宣言 } public Playing: boolean; Folder: string; LastPlayIndex,PlayIndex: integer; procedure PlayNext; end; TPlayMode = (pmAll, pmSelected, pmSingle); var Form1: TForm1; PlayMode: TPlayMode; implementation {$R *.DFM} procedure TForm1.FormShow(Sender: TObject); var Ini: TInifile; begin Ini := TInifile.Create(ChangeFileExt(Application.ExeName, '.ini')); try Folder := Ini.ReadString('FILES','FOLDER', ''); if Folder <> '' then begin DirectoryListBox1.Directory := Folder; end; finally Ini.Free; end; SetPriorityClass( GetCurrentProcess, HIGH_PRIORITY_CLASS ); end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var Ini: TInifile; begin Ini := TInifile.Create(ChangeFileExt(Application.ExeName, '.ini')); try if Folder <> '' then Ini.WriteString('FILES','FOLDER', Folder); finally Ini.Free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin if Playing then Exit; if FileListBox1.Items.Count > 0 then begin Folder := DirectoryListBox1.Directory; PlayMode := pmAll; PlayIndex := -1; LastPlayIndex := FileListBox1.Items.Count -1; MP1.Notify := True; PlayNext; end; end; procedure TForm1.PlayNext; var F, Ext: string; begin Playing := False; MP1.Close; case PlayMode of pmAll: begin Panel3.Hide; if PlayIndex < LastPlayIndex then begin inc(PlayIndex); F := Folder +'\'+ FileListBox1.Items[PlayIndex]; Ext := AnsiLowerCase(ExtractFileExt(F)); if Ext = '.wav' then begin MP1.FileName := F; MP1.Open; MP1.Play; end else if Ext = '.mpeg' then begin Panel3.BringToFront; Panel3.Show; Panel3.Update; MP1.FileName := F; MP1.Open; MP1.DisplayRect := Rect(0,0,Panel3.Width, Panel3.Height); MP1.Play; end; Application.ProcessMessages; Label3.Caption := FileListBox1.Items[PlayIndex]; Label1.Caption := FormatCurr('0',PlayIndex+1)+'/'+FormatCurr('0',LastPlayIndex+1); Playing := True; end; end; end; end; procedure TForm1.MP1Notify(Sender: TObject); begin if (MP1.Mode = mpPlaying) and Playing then begin Playing := False; PlayNext; end; end; procedure TForm1.Button4Click(Sender: TObject); begin if Playing then begin Playing := False; MP1.Close; Panel3.Hide; end; end; procedure TForm1.Button5Click(Sender: TObject); begin PlayNext; end; procedure TForm1.Button3Click(Sender: TObject); begin if PlayIndex >= 0 then dec(PlayIndex) else if LastPlayIndex >= 0 then PlayIndex := LastPlayIndex ; if PlayIndex >= 0 then dec(PlayIndex) else if LastPlayIndex >= 0 then PlayIndex := LastPlayIndex ; PlayNext; end; end. TN(CQJ01721)  Original document by TN 氏 ID:(CQJ01721)



ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum