Autor Beitrag
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 11.05.05 22:47 
www.krazz.net/retnyg/tut/mptut1.htm

ein kleines tutorial für den TMediaplayer.

fragen dazu hier posten, bei bedarf/interesse werde ich auch demonstrieren wie man z.b. durch eine playlist iteriert.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
pontoffeltier
Hält's aus hier
Beiträge: 5



BeitragVerfasst: So 05.06.05 01:49 
mach das mal
wär nett wenn du mir den link dann per mail oda icq schiggn könntest
[edit: persönliche daten entfernt]
danke


Zuletzt bearbeitet von pontoffeltier am So 24.10.10 09:39, insgesamt 1-mal bearbeitet
xxx244
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 58

WIN XP SP2
Delphi 2005 Personal
BeitragVerfasst: Mo 06.06.05 18:53 
HAllo!
Ich würde es gut finden, wenn du noch weiter schreibst.
Mich würd das mit der Playlist mal interressieren.
Adrian
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.06.05 15:29 
Neue Version Online:
- Arbeiten mit einer Playlist
- Arbeiten mit dem OnNotify-Event zur Erkennung eines Liedendes.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
xxx244
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 58

WIN XP SP2
Delphi 2005 Personal
BeitragVerfasst: Di 07.06.05 17:36 
Also ich find da keine neue Version!
Vielleicht ein falscher Link!

//EDIT:Geht jetzt!Link wurd irgendwie bei erstemal nicht mitgeladen
Aber als ich den Frame neugeladen hab gings:


Zuletzt bearbeitet von xxx244 am Mi 08.06.05 15:06, insgesamt 2-mal bearbeitet
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.06.05 17:39 
doch...du musst allerdings unten auf der seite den link...weiter zu kapitel 2 anklicken.
und falls das da unten nicht steht, musst du bei deinem browser entweder auf aktualisieren klicken, nen rechtsklick auf die seite machen und this frame->reload oder den cache bzw offlineinhalte leeren (unter einstellungen)

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Di 07.06.05 17:40 
user profile iconxxx244 hat folgendes geschrieben:
Also ich find da keine neue Version!
Vielleicht ein falscher Link!

Ganz unten findest du immer einen Link zum neuen Kapitel... ;)

//EDIT: Mist... :motz: Zu spät... ;)
Fisheye
Hält's aus hier
Beiträge: 11



BeitragVerfasst: So 12.06.05 18:55 
Ich habe ein problem mit dem Mp3 Player.

Ich hab das Tutorial durch die Kompillierung geht auch ohne Probleme. Nur wenn es in der Playlist zum nächsten weiterspringt stürzt der Mp3 Player beim 3 weiterspringen immer ab :cry:

//Edit : Ich habe meinen neuen Quellcode hier reinkpiert. Hab inzwischen einen Lautsärken regeler eingebaut, der tadellos funktioniert :wink: Die Fehler sind leider immer noch da

ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
unit Unit3_form3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, MPlayer, ShellApi, ComCtrls, mmsystem;

type
  TForm3 = class(TForm)
    MediaPlayer1: TMediaPlayer;
    ListBox1: TListBox;
    TrackBar1: TTrackBar;
    procedure TrackBar1Change(Sender: TObject);
    procedure ListBox1DblClick(Sender: TObject);
    procedure MediaPlayer1Notify(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Procedure AddToPlaylist(s:String);
    Procedure PlayFile(SongNumber:Integer);
    Procedure WMDropFiles (Var aMsg: tMessage);  message WM_DROPFILES;
  end;

var
  Form3: TForm3;
  PlayList : TStringList;
  CurrentSong : Integer = -1;

implementation

function SetWaveVolume(const AVolume: DWord) : boolean;
var
  WaveOutCaps : TWAVEOUTCAPS;
begin
  Result := False;
  if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, sizeof(WaveOutCaps)) = MMSYSERR_NOERROR then
  if WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
  Result := WaveOutSetVolume(-1, AVolume) = MMSYSERR_NOERROR;
end;

function GetWaveVolume(var LVol:DWord; var RVol:DWord) : Boolean;
var
  WaveOutCaps : TWAVEOUTCAPS;
  Volume : DWord;
begin
  Result := false;
  if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, SizeOf(WaveOutCaps)) = MMSYSERR_NOERROR then
  if WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
  begin
    Result := WaveOutGetVolume(-1, @Volume) = MMSYSERR_NOERROR;
    LVol := LoWord(Volume);
    RVol := HiWord(Volume);
  end;
end;



Procedure TForm3.WMDropFiles (Var aMsg: tMessage);  // Drag & Drop Procedure
Var
  Idx, Size, FileCount: Integer;
  Filename: pChar;
Begin
  Inherited;
  FileCount := DragQueryFile (aMsg.WParam, $FFFFFFFFnil255);
  For Idx := 0 To FileCount -1 Do Begin
    Size := DragQueryFile (aMsg.WParam, Idx, nil0) + 1;
    Filename := StrAlloc (Size);
    If DragQueryFile (aMsg.WParam, Idx, Filename, Size) = 1 Then  { nothing }
    else  AddToPlayList (pChar (Filename)); // hier wird das jeweilige file unserer Prozedur AddToPlaylist überwiesen.
    StrDispose (Filename);
  End;
  DragFinish (aMsg.WParam);
End;

Procedure Tform3.AddToPlaylist(s:string);
begin
  PlayList.Add(s);
  ListBox1.Items.Add(extractfilename(s));
end;




{$R *.dfm}


procedure TForm3.FormCreate(Sender: TObject);
begin
  DragAcceptFiles (Handle, True);  // Drag & Drop Akzeptieren
  PlayList := TStringList.Create;  // TStringList erstellen
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
  PlayList.Free;
end;


 Procedure Tform3.PlayFile(Songnumber:Integer);
begin
  If FiLeExists(PlayList.Strings[SongNumber])
  then
    begin CurrentSong := SongNumber;
  MediaPlayer1.Close;
  MediaPlayer1.FileName := PlayList.Strings[SongNumber];
  MediaPlayer1.Open;
  MediaPlayer1.Play;
  end;
end;



procedure TForm3.MediaPlayer1Notify(Sender: TObject);
begin
if mediaplayer1.Position = mediaplayer1.Length then begin
   // position = gesamtlänge, bedeutet dass das lied beendet wurde
     Listbox1.Selected[currentSong] := false; // das gerade gespielte lied de-selektieren
     inc(currentSong); // aktuellen song um eines erhöhen
     if currentSong < Playlist.Count then { alles passt, songindex im rahmen}
     else currentsong := 0{ende der liste erreicht, setze aktuelles lied auf anfang}
     PlayFile(CurrentSong);
     Listbox1.Selected[currentSong] := true; // das aktuelle lied selektieren
   end;
end;


procedure TForm3.ListBox1DblClick(Sender: TObject);
var
i : integer;
begin
for i := 0 to ListBox1.Count - 1 do
  if ListBox1.Selected[i]
    then Break;
  PlayFile(i);
end;

procedure TForm3.TrackBar1Change(Sender: TObject);
begin
  SetWaveVolume (MakeLong((65535 div 100) * Trackbar1.Position, (65535 div 100) * Trackbar1.Position)) ;
end;

end.


Ich hoffe ihr könnt mir helfen


Zuletzt bearbeitet von Fisheye am Mo 13.06.05 16:51, insgesamt 2-mal bearbeitet
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 03:14 
user profile iconFisheye hat folgendes geschrieben:

Nur wenn es in der Playlist zum nächsten weiterspringt stürzt der Mp3 Player beim 3 weiterspringen immer ab :cry:
Ich hoffe ihr könnt mir helfen


hmm ich hab das mal kompiliert (nur form3 in form1 geändert) - funktioniert tadellos bei mir
versuche mal einen breakpoint in das notify-event und dann mit einzelschritt ( F7 ) durchgehen und immer die variablen kontrollieren. welche delphi-version verwendest du ?

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Fisheye
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Mo 13.06.05 16:13 
z.Z. Benutze Ích die Delphi 2005 Trial

Ich habe jetzt mal in allen Prozeduren breakpunkte gesetzt.

Dabei tratem folgende fehler auf

ausblenden Quelltext
1:
2:
3:
4:
Source Breakpoint at $00457E60: C:\Dokumente und Einstellungen\Fish\Eigene Dateien\Borland Studio Projects\Mp3player\Unit3_form3.pas line 146. Process Mp3player.exe (3012)
Source Breakpoint at $00457C6C: C:\Dokumente und Einstellungen\Fish\Eigene Dateien\Borland Studio Projects\Mp3player\Unit3_form3.pas line 92. Process Mp3player.exe (3012)
Source Breakpoint at $00457C7E: C:\Dokumente und Einstellungen\Fish\Eigene Dateien\Borland Studio Projects\Mp3player\Unit3_form3.pas line 94. Process Mp3player.exe (3012)
Source Breakpoint at $00457C8F: C:\Dokumente und Einstellungen\Fish\Eigene Dateien\Borland Studio Projects\Mp3player\Unit3_form3.pas line 95. Process Mp3player.exe (3012)


Fisheye
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 13.06.05 22:14 
das sagt mir ziemlich wenig, bei dem code oben entsprechen die codezeilen dem Tform1.create, bzw dem end. ganz am schluss ^^
bei welcher code-zeile hängt er sich auf ?

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Mi 17.08.05 19:22 
Ich hab das tutorial auch mal gemacht nur kommt dann bei mir der zeile
ausblenden Delphi-Quelltext
1:
if currentSong < Playlist.Count then					

der Fehler das das Maximum der Liste überschritten wird, kann mir bitte jemand sagen woran das liegt?
mmh ich verwend delphi3 Pro

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 17.08.05 20:11 
Ohne jetzt das Tutorial wirklich durchgemacht zu haben: Probier mal

ausblenden Delphi-Quelltext
1:
if currentSong < Playlist.Count-1 then					
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 17.08.05 20:15 
tutorial finde ich auch sehr schön, fehlte irgendwie noch ne lautstärke regelung, das versuch ich schon ewig hinzubekommen, aber irgendwie klappts nie :roll:
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 17.08.05 20:17 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
tutorial finde ich auch sehr schön, fehlte irgendwie noch ne lautstärke regelung, das versuch ich schon ewig hinzubekommen, aber irgendwie klappts nie :roll:

Das solltest du über das MMSystem hinbekommen.

:arrow: www.delphi-forum.de/...ghlight=lautst%E4rke
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 17.08.05 20:23 
so in etwa:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Procedure LowerVol(Percent: Integer);  
Var  
    i: Integer;  
Begin  
    If (Percent <= 100And (Percent >= 1Then  
        For i := 1 To (Percent Div 2) + 1 Do  
            SendMessage(Application.Handle, WM_Command, 400590);  
End;  
 
Procedure RaiseVol(Percent: Integer);  
Var  
    i: Integer;  
Begin  
    If (Percent <= 100And (Percent >= 1Then  
        For i := 1 To (Percent Div 2) + 1 Do  
            SendMessage(Application.Handle, WM_Command, 400580);  
End;

? werde ich mal testen ;)

edit: tut sich nischt :roll:


Zuletzt bearbeitet von F34r0fTh3D4rk am Mi 17.08.05 20:26, insgesamt 1-mal bearbeitet
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Mi 17.08.05 20:24 
argh, bin beim kopiern in der zeile verrutscht sry, dort komm der fehler
ausblenden Delphi-Quelltext
1:
inc(currentSong);					


Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 17.08.05 20:32 
ich arbeite auch schon seit längerem an meinem mp3 player, vielleicht kannst du ja was mit meiner notify prozedur anfangen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TMainForm.MPlayerNotify(Sender: TObject);
var
  track: integer;
begin
  if mplayer.Position = mplayer.Length then
    begin
     (*Gekürzt ;) *)
     track := current;
     if not random_play then
       begin
         inc(track);
         if track > (high(MP3s) - 1then
           track := 0;
       end else
         track := random(high(MP3s) - 1);
     Play(track);
   end;  
end;
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 17.08.05 20:43 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
so in etwa:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Procedure LowerVol(Percent: Integer);  
Var  
    i: Integer;  
Begin  
    If (Percent <= 100And (Percent >= 1Then  
        For i := 1 To (Percent Div 2) + 1 Do  
            SendMessage(Application.Handle, WM_Command, 400590);  
End;  
 
Procedure RaiseVol(Percent: Integer);  
Var  
    i: Integer;  
Begin  
    If (Percent <= 100And (Percent >= 1Then  
        For i := 1 To (Percent Div 2) + 1 Do  
            SendMessage(Application.Handle, WM_Command, 400580);  
End;

? werde ich mal testen ;)

edit: tut sich nischt :roll:

is klar, nö ? siehst du irgendwo einen code der die lautstärke beeinflussen soll ?
ich sehe code der eine windowmessage an ein programm abschickt.
das is der code um bei winamp die lautstärke zu verstellen :roll:
das das in deinem programm nix bewirkt, ist also logisch

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 17.08.05 21:06 
ausblenden Delphi-Quelltext
1:
WM_Command, 40058					

dachte dass des auch hier funzt, oder ist das winamp spezifisch ?

hast du was anderes auf lager ?