Pomocy Media Player playlista odtwarzanie

0

Witam
Jestem początkujący i bardzo chce napisać playliste do komponentu mediaplayer Potrafię napisać aby odtwarzał wybrany plik ale nie mam pojęcia jak zrobić aby po zakończeniu odtwarzania odtwarzał on następny plik bez klikania.Play lista jest w listbox

0
if MediaPlayer1.Position=MediaPlayer1.Length then
begin
ListBox1.ItemIndex:=ListBox1.ItemIndex+1;
//inne do odtwarzania jak np. MediapLayer1.Play :D
end;

aaa.. i wstaw to do timera

0

Dzieki piękne wszystko ok tylko teraz wyskakuje mi błąd Project Project1.exe raised exection class EMCIDeviceError with message 'No MCI device' Proces stopped.</image>

0

dodaj w if :

MediaPlayer1.FileName := 'tutaj nazwa pliku z listboxa';
MediaPlayer1.Play;

EDIT:
ps. daj kod. nie jesteśmy wróżkami :)

0

a ja dałbym jeszcze dodatkowo warunek:

if Listbox1.ItemIndex < ListBox1.Items.Count-1 then begin

...

end;

0

a ja bym to wsadził w

try
.....
except
.....

:D

0

unit Unit1;

interface

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

type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
ScrollBar1: TScrollBar;
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
FileListBox1: TFileListBox;
Timer1: TTimer;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
procedure Timer1Timer(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FileListBox1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
{ Private declarations }
public
procedure odtworz;
end;

var
Form1: TForm1;
sc:boolean;
implementation

{$R *.dfm}
procedure TForm1.FileListBox1Click(Sender: TObject);
begin
MediaPlayer1.FileName:=FileListBox1.FileName;
//MediaPlayer1.Open;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
if sc=true then
ScrollBar1.Position:=MediaPlayer1.Position;
end;

procedure tform1.odtworz;
begin
if FileListBox1.ItemIndex=FileListBox1.Items.Count then
begin
MediaPlayer1.Stop;
MediaPlayer1.Close;
end
else
begin
sc:=true;
MediaPlayer1.FileName:=FileListBox1.FileName;
MediaPlayer1.Open;
MediaPlayer1.Play;
ScrollBar1.Min:=0;
ScrollBar1.Max:=MediaPlayer1.Length;
end;
end;

procedure TForm1.ScrollBar1Change(Sender: TObject);
begin
if ScrollBar1.Position=MediaPlayer1.Length then
begin
MediaPlayer1.Close;
FileListBox1.Itemindex:=FileListBox1.ItemIndex+1;
if sc=true then
begin
MediaPlayer1.FileName:=FileListBox1.FileName;
odtworz;
end;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
MediaPlayer1.Position:=0;
sc:=false;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
odtworz;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
MediaPlayer1.Stop;
ScrollBar1.Position:=0;
end;

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
FileListBox1.Itemindex:=FileListBox1.ItemIndex+1;
odtworz;
end;

procedure TForm1.SpeedButton4Click(Sender: TObject);
begin
FileListBox1.Itemindex:=FileListBox1.ItemIndex-1;
odtworz;
end;

end.

Oto kod udało mi się zrobić aby odtwarzał kolejne ale nie wiem teraz jak napisać zmiane pozycji odtwarzacz czyli przewijanie piosenek

1 użytkowników online, w tym zalogowanych: 0, gości: 1