急!!关于TWindowsMediaPlayer播放列表的问题???(100分)

  • 主题发起人 主题发起人 szkwwm
  • 开始时间 开始时间
S

szkwwm

Unregistered / Unconfirmed
GUEST, unregistred user!
在DELPHI中如何加载TWindowsMediaPlayer的播放列表,并指定其中的某一文件为播放起始文件???请高手进,急啊!
 
我有源代码 你要给300分
 
楼上的兄弟,你也太黑了吧,我只有400分不到了,我现在只是有一点点问题没有解决,能不能少一点。
 
没有高手进吗?
 
算了我就贴出来好了 给你个烂点的unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FileCtrl, ExtCtrls, MPlayer, ComCtrls;

type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Timer1: TTimer;
TrackBar1: TTrackBar;
FileListBox1: TFileListBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FileListBox1Change(Sender: TObject);
procedure TrackBar1DragDrop(Sender, Source: TObject;
X, Y: Integer);
procedure TrackBar1EndDrag(Sender, Target: TObject;
X, Y: Integer);
private
{ Private declarations }
procedure PlayAvi();
public
{ Public declarations }
end;


var
Form1: TForm1;
g_index :Integer;

implementation

{$R *.dfm}
procedure TForm1.PlayAvi();
begin

if g_index = FileListBox1.Count then

g_index := 0;
MediaPlayer1.FileName:=FileListBox1.Items[g_index];
MediaPlayer1.Open;
MediaPlayer1.Display := Panel1;
MediaPlayer1.DisplayRect := Rect(0,0,Panel1.Width,Panel1.Height);
MediaPlayer1.Play;
TrackBar1.Min := 0;
TrackBar1.Max := MediaPlayer1.Length;
TrackBar1.Position := 0;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

FileListBox1.Clear;
if OpenDialog1.Execute then

begin

FileListBox1.Items := OpenDialog1.Files;
end;

MediaPlayer1.Close;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin

PlayAvi();
end;


procedure TForm1.Timer1Timer(Sender: TObject);
begin

if MediaPlayer1.Mode = mpPlaying then

TrackBar1.Position := MediaPlayer1.Position;
if (MediaPlayer1.Mode = mpStopped)and(MediaPlayer1.Position = MediaPlayer1.Length) then

begin

g_index := g_index+1;
PlayAvi();
end;

end;


procedure TForm1.FileListBox1Change(Sender: TObject);
begin

g_index := FileListBox1.ItemIndex ;
// PlayAvi();
end;



procedure TForm1.TrackBar1DragDrop(Sender, Source: TObject;
X, Y: Integer);
begin

Timer1.Enabled := False;
MediaPlayer1.Position := TrackBar1.Position;
end;


procedure TForm1.TrackBar1EndDrag(Sender, Target: TObject;
X, Y: Integer);
begin

Timer1.Enabled := True;
end;


end.
 
呵呵,感谢楼上的兄弟,不过我需要的是TWindowsMediaPlayer,不是TMediaPlayer,我现在是这么写的,不过有些问题:
  //VideoList存储的URL列表
for i := 0 to VideoList.Lines.Count - 1do

begin

PlayVideo := MHDPlayer.newMedia(VideoList.Lines.Strings);
if MHDPlayer.currentPlaylist.count = 0 then

MHDPlayer.currentMedia := PlayVideo
else

MHDPlayer.currentPlaylist.appendItem(PlayVideo);
end;

------------
现在调试程序时,加载URL的过程会报系统错误,类似于地址错误,不知是何原因引起,直接运行EXE,不会有错,但播放不出来???
 
procedure TfrmMain.FormShow(Sender: TObject);
var
playvideo : IWMPMedia;
begin

PlayVideo := WindowsMediaPlayer1.newMedia('E:/测试.mpg');
WindowsMediaPlayer1.currentMedia := playvideo;
WindowsMediaPlayer1.controls.play;
end;

--------------------
求高手解决啊,现在这段程序无法播放???不知是何原因???
 
后退
顶部