I hope I am just missing something somewhere,I want a custom notification sound to be played when my local notification is fired.
On a new form I dropped down 2 buttons, btnnotification and btnmediaplayer
procedure TForm1.btnnotificationClick(Sender: TObject);
MyNotification : TNotification;
MyNotification := NotificationCenter1.CreateNotification;
MyNotification.EnableSound := True;
MyNotification.SoundName := TPath.Combine(TPath.GetDocumentsPath, ‘Siren.mp3’);
MyNotification.Name := ‘mynote’;
MyNotification.AlertBody := ‘Test’;
MyNotification.FireDate := Now;
ShowMessage(MyNotification.SoundName); //<– Points towards a valid filepath
I added the Siren file to the internal assets in deployment, the notification fires but there is no sound, I then added another button and this time I am just using a TMediaplayer
procedure TForm1.btnmediaplayerClick(Sender: TObject);
MediaPlayer1.FileName := TPath.Combine(TPath.GetDocumentsPath, ‘Siren.mp3’);
ShowMessage(MediaPlayer1.FileName);//<–Points towards the same path as the notification
With the TMediaplayer it works no problems, which means the file does exists, I have now tried this with 2 different devices : Xperia Z2 And a Samsung Note 2 both running Andriod V4.4.2 ,
and both devices have their notification volume set to max but still no sound.
I tried it on a Samsung Tab3 running 4.1.2 which means its not a 4.4.2 issue
I tried manually copying the file in the com.andriod.project folder
but still no sound on the notification.
Solved : You need to have the sound stored Externally and use GetSharedDocumentsPath, storing it internally and using GetDocumentsPath doesn’t work