Autor Beitrag
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 12.05.06 16:50 
Hi,
ich will in eines meiner Programme im Hintergrund z.B 5 Musikstücke nach Zufallsprinzip
abspielen lassen, habe aber nirgends etwas gefunden :bawling: Welche Komponente brauch ich dafür?
Oder kann mir jemand sagen wo es Tuts dafür gibt :?:

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Fr 12.05.06 17:22 
Du kannst einfach die Komponente MediaPlayer (unter System) verwenden, einfach Random(5) machen und dann, je nach Zahl, das jeweilige Lied abspielen. Mit Hide kannst du ihn verstecken, so das ihn niemand sieht.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 12.05.06 17:31 
Danke für das schnelle Feedback
Bei mir funktioniert dass aber irgendwie nicht :roll:
ich mache es so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormCreate(Sender: TObject);
begin
  MediaPlayer1.Hide := true;
end;

kann mir jemand sagen wie dass geht

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Fr 12.05.06 17:33 
Einfach nur


ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormCreate(Sender: TObject);  
begin  
  MediaPlayer1.Hide;  
end;


//EDIT: Vertippt, Sry
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 12.05.06 17:35 
Jetzt funktioniert es
Daanke für deine Hilfe :beer:

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 12.05.06 17:38 
Achso brauch ich dafür nen OpenFile Dialog?

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Fr 12.05.06 17:45 
Ich hab mal schnell was gebastelt, schaus dir mal an.
Einloggen, um Attachments anzusehen!
Barzi
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 12.05.06 17:51 
Ehm... kann mir jemand das nochmal genauer erklären? :?:
Irgentwie kapier ich das noch nicht wie man dem MediaPlayer sagt welche Musikstücke er abspielen soll.

Danke im Vorraus :wink:
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Fr 12.05.06 17:58 
Danke
muss jetzt weg.
Das Beispiel funktioniert (wenn man Liedlänge in Liedlaenge und als Integer macht.
Ich sag euch wenn es geht.
Leuchtturm

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Fr 12.05.06 18:00 
Schau dir mal den Beispiel Code an.
Also der MediaPlayer muss zuerst mit einer Datei verbunden werden also die Eigenschaft .FileName. Dann muss die Datei geöffnet werden also .Open, dann kannst dus wiedergeben mit .Play. Wenn des Lied dann abgelaufen ist, musst du die Datei schließen (.Close), davor am besten noch .Stop, ich weiß aber net obs unbedingt notwendig ist.
Barzi
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 12.05.06 18:02 
:beer:

Es funktioniert... Danke

:zustimm:
Barzi
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 12.05.06 18:23 
Eine Frage noch: Was für ein Befehl steht für Pause? Vieleicht .pause ???
Barzi
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 12.05.06 18:30 
Es war wirklich '.pause'
Nächstes mal probier ich aus bevor ich euch mit dähmlichen Fragen nerve :D
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 13.05.06 13:10 
@Hack Gott:Danke für deine Hilfe es funktioniert :zustimm:

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 13.05.06 15:09 
Wie kann man dass jetzt in einer schleife ablaufen lassen.
Hatte noch nichts mit schleifen zutun

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
DaKirsche
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 187

Win XP Pro, SuSe Linux 7.3 - 10.2, Win 2k3 Server, Win 2000, Win NT 4.0
Delphi 2006 Pro, Java, HTML, SQL, PHP, CSS
BeitragVerfasst: Sa 13.05.06 15:32 
kannst ja nachdem das Musikstück abgespielt ist mit .stop bzw. .close schliessen und startest dann ein neues Lied, welches per Zufall ausgewählt wird.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.RandomSongStart();
var song : Integer:
dir : String;
begin
song := random(5) +1;
dir := ExtractFilePath(ParamStr(0)) + '\';  //Programmverzeichnis
case song of //Abfrage des Songs
1 : Mediaplayer1.Filename:=dir + '\Musik\song1.mp3';
2 : Mediaplayer1.Filename:=dir + '\Musik\song2.mp3';
3 : Mediaplayer1.Filename:=dir + '\Musik\song3.mp3';
4 : Mediaplayer1.Filename:=dir + '\Musik\song4.mp3';
5 : Mediaplayer1.Filename:=dir + '\Musik\song5.mp3';
end;
MediaPlayer1.Open;
MediaPlayer1.Play;
end;

procedure TFrom1.MusikTimer(Sender: TObject);
begin
if (MediaPlayer1.TrackPosition = MediaPlayer1.TrackLenght) then begin  //Abfrage ob Trackposition = Tracklänge ist
MediaPlayer1.Rewind;
MediaPlayer1.Stop;
MediaPlayer1.Close;
RandomSongStart();
end;
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 13.05.06 15:35 
Danke

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 13.05.06 15:45 
Ps: Ich mache es jetzt doch nur mit einem Lied und habe so fast alles ausprobiert, aber ich bekomme es nicht hin dass es auch mit einem Lied funktioniert

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
DaKirsche
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 187

Win XP Pro, SuSe Linux 7.3 - 10.2, Win 2k3 Server, Win 2000, Win NT 4.0
Delphi 2006 Pro, Java, HTML, SQL, PHP, CSS
BeitragVerfasst: Sa 13.05.06 15:54 
Dann setze mal AutoRewind und AutoOpen auf True und das Lied sollte automatisch von vorne anfangen...
Leuchtturm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 13.05.06 15:58 
Da bekomme ich den Fehler:
Exception EMCIDeviceError in Modul Programm.exe bei 00070668.
Kann keinen Gerätetyp aus der angegebenen Dateinamenerweiterung ermitteln.
Ich benutze Wav

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.