MEDİA PLAYER ARDI ARDINA ÇALMA

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
vedatkaba
Kıdemli Üye
Mesajlar: 866
Kayıt: 06 Oca 2004 06:50
Konum: DARICA/GEBZE

MEDİA PLAYER ARDI ARDINA ÇALMA

Mesaj gönderen vedatkaba »

ARKADAŞLAR HERKESE KOLAY GELSİNN,,,
MÜZİK DİNLEMEK İÇİN YAPMAYA ÇALIŞTIĞIM BİR ÇALIŞMA VAR..HERŞEY TAMAMDA ARDI ARDINA ŞARKI ÇALMAYI YAPAMADIK,,DAHA ÖNCEDE BU SORUN VARDI FORUMADA SORMUŞTUM O KODU BU KEZ ÇALIŞTIRAMADIM DDEĞİŞİK ŞEKİLDEDE DENESEMDE OLMADI.PROGRAMIN KODLARI ŞÖLE

KULLANDIĞIM BİLEŞEN VE ÖZELLİKLERİ
prev: TsuiButton;
next: TsuiButton;
mp3: TMediaPlayer;
paths: TRzListBox;
second: TTimer;
parametr: TTimer;
placepos: TTimer;
time: TRzPanel;
total: TRzPanel;
liste: TsuiListBox;

Kod: Tümünü seç

procedure TForm1.FormCreate(Sender: TObject);
var
vol:word;
a:string;
f:file;
begin
a:=extractfilepath(application.ExeName);
close;
audio1.Player.GetVolume(vol,vol);
volume.Position:=round(100/65535*(65535-vol));
if paramcount<>0 then
if pos('.',paramstr(1))<>0 then
begin
parametre(paramstr(1));
end;
if not fileexists(a+'mp3liste.dll') then
begin
assignfile(f,a+'mp3liste.dll');
rewrite(f);
closefile(f);
end;
if not fileexists(a+'path.dll') then
begin
assignfile(f,a+'path.dll');
rewrite(f);
closefile(f);
end;
liste.Items.LoadFromFile(a+'mp3liste.dll');
paths.Items.LoadFromFile(a+'path.dll');

end;

Kod: Tümünü seç

procedure TForm1.listeDblClick(Sender: TObject);
begin
if paths.Items.strings[liste.ItemIndex]<>mp3.FileName then
begin
placebar.Enabled:=false;
prev.Enabled:=false;
next.Enabled:=false;
liste.Enabled:=false;
second.Enabled:=false;
close;
fillinfo(paths.Items.Strings[liste.itemindex],paths.Items.Strings[liste.itemindex]);
mp3.Close;
mp3.FileName:=paths.Items.Strings[liste.itemindex];
mp3.Open;
placebar.Max:=mp3.Length;
mp3.Play;
second.Enabled:=true;
end;
end;

Kod: Tümünü seç

procedure TForm1.playClick(Sender: TObject);
begin
if mp3.FileName<>'' then
begin
mp3.Play;
placebar.Max:=mp3.Length;
placepos.Enabled:=true;
end
else
if liste.count=1 then
begin
liste.ItemIndex:=0;
songok;
END
else
if liste.ItemIndex<0 then
liste.ItemIndex:=0;
songok;
end;

Kod: Tümünü seç

procedure TForm1.songok;
begin
if paths.Items.strings[liste.ItemIndex]<>mp3.FileName then
begin
placebar.Enabled:=false;
second.Enabled:=false;
close;
fillinfo(paths.Items.Strings[liste.itemindex],paths.Items.Strings[liste.itemindex]);
mp3.Close;
mp3.FileName:=paths.Items.Strings[liste.itemindex];
mp3.Open;
placebar.Max:=form1.mp3.Length;
mp3.Play;
second.Enabled:=true;
end;

end;

Kod: Tümünü seç

procedure TForm1.shuffClick(Sender: TObject);
begin
if shuf=true then
begin
shuff.Caption:='Shuff';
shuf:=false
end
else
begin
shuff.Caption:='* Shuff';
shuf:=true;
end;
end;

Kod: Tümünü seç

procedure TForm1.mp3Notify(Sender: TObject);
begin
with mp3 do
begin
if mode=mpstopped then
if time.Caption=total.Caption then
begin
form1.nextClick(sender);
end;
notify:=true;
end;
end;
DEĞİŞKENLER




HERKESE KOLAY GELSİN İYİ ÇALIŞMALAR ..
var
Form1: TForm1;
cretids,volu,repe,shuf:boolean;
secondplace:word;
songname,songadres:string;
mo,tut:boolean;
tikla:integer;
posa:Tpoint;
***********************************
Kamil odur ki; koya dünyada bir eser,
Eseri olmayanın, yerinde yeller eser.

***********************************
Kullanıcı avatarı
sedarsahin
Üye
Mesajlar: 16
Kayıt: 05 Tem 2004 04:58
Konum: istanbul
İletişim:

Mesaj gönderen sedarsahin »

Lütfen Küçük harfle yazalım
"Nefsini Bilen, Rabbini Bilir"
H.ş
Kullanıcı avatarı
mege
Admin
Mesajlar: 2360
Kayıt: 05 Şub 2004 04:32
Konum: Beşiktaş
İletişim:

Mesaj gönderen mege »

viewtopic.php?p=11883#11883

Kod: Tümünü seç

procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
 with Sender as TMediaPlayer do
  begin
    if mode=mpstopped then Play;
    Notify := True;
  end;
end; 
.-.-.-.-.-.-.-. ^_^
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Mesaj gönderen mrmarman »

@vedatkaba

- Öncelikle büyük harf konusunda dikkatli olalım. :!: Sadece bu forumda değil, diğerlerinde de önemlidir. Gereksiz yere büyük harf kullanmak yüksek sesle konuşmak / alay etmek gibi anlamlardan dolayı saygısızlık ifadesi içerir... :idea:

- Soruna gelince, kKodların çok karışık... Senin için toparlıyorum..

Kod: Tümünü seç

var
  Form1: TForm1;
  cretids, volu, repe, shuf: boolean;
  secondplace: word;
  songname, songadres: string;
  mo, tut: boolean;
  tikla: integer;
  posa: Tpoint;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  vol: word;
  a: string;
  f: file;
begin
  a := extractfilepath(application.ExeName);
  close;
  audio1.Player.GetVolume(vol, vol);
  volume.Position := round(100 / 65535 * (65535 - vol));
  if paramcount <> 0 then
    if pos('.', paramstr(1)) <> 0 then
    begin
      parametre(paramstr(1));
    end;
  if not fileexists(a + 'mp3liste.dll') then
  begin
    assignfile(f, a + 'mp3liste.dll');
    rewrite(f);
    closefile(f);
  end;
  if not fileexists(a + 'path.dll') then
  begin
    assignfile(f, a + 'path.dll');
    rewrite(f);
    closefile(f);
  end;
  liste.Items.LoadFromFile(a + 'mp3liste.dll');
  paths.Items.LoadFromFile(a + 'path.dll');
end;

procedure TForm1.ListeDblClick(Sender: TObject);
begin
  if paths.Items.strings[liste.ItemIndex] <> mp3.FileName then
  begin
    placebar.Enabled := false;
    prev.Enabled := false;
    next.Enabled := false;
    liste.Enabled := false;
    second.Enabled := false;
    close;
    fillinfo(paths.Items.Strings[liste.itemindex], paths.Items.Strings[liste.itemindex]);
    mp3.Close;
    mp3.FileName := paths.Items.Strings[liste.itemindex];
    mp3.Open;
    placebar.Max := mp3.Length;
    mp3.Play;
    second.Enabled := true;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if mp3.FileName <> '' then
  begin
    mp3.Play;
    placebar.Max := mp3.Length;
    placepos.Enabled := true;
  end
  else
    if liste.count = 1 then
    begin
      liste.ItemIndex := 0;
      songok;
    end
    else
      if liste.ItemIndex < 0 then
        liste.ItemIndex := 0;
  songok;
end;

procedure TForm1.songok;
begin
  if paths.Items.strings[liste.ItemIndex] <> mp3.FileName then
  begin
    placebar.Enabled := false;
    second.Enabled := false;
    close;
    fillinfo(paths.Items.Strings[liste.itemindex], paths.Items.Strings[liste.itemindex]);
    mp3.Close;
    mp3.FileName := paths.Items.Strings[liste.itemindex];
    mp3.Open;
    placebar.Max := form1.mp3.Length;
    mp3.Play;
    second.Enabled := true;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  begin
    if shuf = true then
    begin
      shuff.Caption := 'Shuff';
      shuf := false
    end
    else
    begin
      shuff.Caption := '* Shuff';
      shuf := true;
    end;
  end;
end;

procedure TForm1.mp3Notify(Sender: TObject);
begin
  begin
    with mp3 do
    begin
      if mode = mpstopped then
        if time.Caption = total.Caption then
        begin
          form1.nextClick(sender);
        end;
      notify := true;
    end;
  end;
end;

end.
@vedatkaba yazdı:DAHA ÖNCEDE BU SORUN VARDI FORUMADA SORMUŞTUM O KODU BU KEZ ÇALIŞTIRAMADIM
.. demişsin, önceki mesajını buldum ama orada da nasıl çözdüğünü yazmamışsın... :roll:

- @mege'nin örneği güzel, ben bunları derlerken yazmış bile... Bu da arama yapmanın faydasına örnekti... :lol:
Resim
Resim ....Resim
Kullanıcı avatarı
vedatkaba
Kıdemli Üye
Mesajlar: 866
Kayıt: 06 Oca 2004 06:50
Konum: DARICA/GEBZE

Mesaj gönderen vedatkaba »

Hocam olmadı ne denediysem olmadı.

formun oncreate olayına

Kod: Tümünü seç

mp3.notify:=true;
diye açtırıp denedim

notify olayına ise

Kod: Tümünü seç

procedure TForm1.mp3Notify(Sender: TObject);
begin
with mp3 do
begin
if mode=mpstopped then
if time.Caption=total.Caption then
begin
play;
mp3.FileName:=paths.Items.Strings[paths.itemindex+1];
end;
notify:=true;
end;
end;
paths list boxta şarkıların yolu belirtilmiş durumda ama yinede olmadı
***********************************
Kamil odur ki; koya dünyada bir eser,
Eseri olmayanın, yerinde yeller eser.

***********************************
Kullanıcı avatarı
hdayi
Kıdemli Üye
Mesajlar: 1284
Kayıt: 29 Oca 2004 01:53
Konum: Erciyes'in eteklerinden.

Mesaj gönderen hdayi »

play;
satırını bir alttaki satırla yer değiştirmek gerek sanırım. MP'ye çal dedikten sonra dosya adı veriyorsunuz oysa çal demeden önce vermek gerekir sanırım.
paths.Items.Strings[paths.itemindex+1]
burada da sanki yanlış bişey var. Hep aynı dosyayı çalar gibime geliyor. Tabi başka yerde ItmeIndex değişmiyorsa...

Kod: Tümünü seç

procedure TForm1.mp3Notify(Sender: TObject);
begin
with mp3 do
begin
  if (mode=mpstopped) and (time.Caption=total.Caption)
  then  begin
    mp3.FileName:=paths.Items.Strings[paths.itemindex+1];
    play;
  end;
  notify:=true;
end;
end;
Kolay gelsin...
Bişnev in ney çün hikâyet mîküned
Ez cüdâyîhâ şikâyet mîküned
Resim
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Mesaj gönderen mrmarman »

@hdayı haklı...

- Ek olarak bu işi Notify'e bırakmasan daha iyi olur gibi geliyor...

- Şöyle özetleyeyim... Bir kere MediaPlayer'in çalarken anlık pozisyonunu Timer nesnesi ile aldığını -nesne tanımlarındaki timer'lerden çıkarımda bulunarak- görüyorum...

- Bu durumda iki farklı tepki süresi ile karşı karşıyasın.. Timer'i 1000 interval (1 saniye) ayarladığını varsayalım, 1 milisaniye önce müzik biterse neye karar verilecek, hiç düşündün mü ?

- Senin toplam süreyi gösteren label ile çalma süresini gösteren time label'in, o Notify zaman diliminde eşit olması 1/1000 ihtimal. 1/1000 doğru bir tabir çünkü 1000 milisaniye 1 saniye :lol:

- Aklıma gelmişken unutmaydan, isimlendirme yaparken nesnelere time, prev, next gibi isimler vermişsin... Bunların önüne veya arkasına takı getirerek boz.. İlerde sorun yaşayabilirsin. Şimdiden elini alıştır... :roll:

- Notify eventini boşalt ve içindekileri Timer'a taşı. Bak örnek olarak aşağıda bir tane hazırladım... :idea:

Kod: Tümünü seç

   with mp3 do
  begin
    if mode = mpStopped then
      if time.Caption = total.Caption then
      begin
        If Paths.Items.Count > (Paths.ItemIndex-1)
          then begin
                 Paths.ItemIndex := paths.itemindex + 1;
                 Liste.ItemIndex := Paths.ItemIndex;
                 FileName := paths.Items.Strings[paths.itemindex];
                 Open;
                 Play;
               end
               else Stop;
      end;
  end;
Resim
Resim ....Resim
Cevapla