Not sure if i do understand the question at all, but ...
You are disabling MediaPlayer1.Notify, while it might be way better keep it true and enabled it every time MediaPlayer1Notify being called.
Also you are checking the wrong state in MediaPlayer1Notify, Notify and OnNotify are associated with
https://learn.microsoft.com/en-us/wi...a/mm-mcinotify
Either i don't know how to find/browse documentation or TMediaPlayer.NotifyValue is missing stuff
https://docwiki.embarcadero.com/Libr...er.NotifyValue
if you need to check if the audio play is finished then check for nvSuccessful like this
Delphi-Quellcode:
procedure TfrmMain.MediaPlayer1Notify(Sender: TObject);
var
sModeString: string;
begin
// Ьberprьfen des aktuellen Modes und in einen lesbaren String umwandeln
{ case MediaPlayer1.Mode of
mpNotReady:
sModeString := 'Not Ready';
mpStopped:
sModeString := 'Stopped';
mpPlaying:
sModeString := 'Playing';
mpRecording:
sModeString := 'Recording';
mpSeeking:
sModeString := 'Seeking';
mpPaused:
sModeString := 'Paused';
mpOpen:
sModeString := 'Open';
else
sModeString := 'Unknown';
end;}
MediaPlayer1.Notify := True;
if MediaPlayer1.NotifyValue = nvSuccessful then
begin
// here check if the the mode was paused or not , the following might be wrong ! and should store the state from OnClick
case MediaPlayer1.Mode of
mpPaused:
MediaPlayer1.Pause;
else
MediaPlayer1.Play;
end;
end;
end;
{-------------------------------------------------------
Procedure: TimerNotifyTimer
Arguments: Sender: TObject
Result: None
### ChangeLog
09.10.2024
------------------------------------------------------}
procedure TfrmMain.TimerNotifyTimer(Sender: TObject);
const
EndTolerance = 1000; // 1 Sekunde Toleranz
begin
{ lbl_Pos.Caption := IntToStr(MediaPlayer1.Position);
if MediaPlayer1.Position >= (MediaPlayer1.Length-EndTolerance) then
begin
MediaPlayer1.Stop;
ShowMessage('Das Musikstьck ist zu Ende.');
MediaPlayer1.Notify := False;
MediaPlayer1.Close;
// Timer explizit freigeben und deaktivieren
TimerNotify.Enabled := False;
end
else
begin
MediaPlayer1.Notify := True;
end; }
end;
And that is it, don't mess with playing and timer for checking it is useless, and as i commented above for pause and continue you need to store the status from different place and distinguish Play vs Pause.
Hope that helps, for me question is still not clear !