Stop Robot.Notifications.PlaySound() logging 'succes' lines

Created at 19 Mar 2021, 11:53
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SH

Shares4us

Joined 01.04.2020

Stop Robot.Notifications.PlaySound() logging 'succes' lines
19 Mar 2021, 11:53


Is there a way to disable the

Notification: PlaySound of 'C:\Users\....mp3' was successful

it cluthers up the log with these useless lines.
If it is NOT succesfull it should log ofcourse or even better:
throw an exception instead of cluthering the log.


@Shares4us
Replies

amusleh
19 Mar 2021, 12:10

Hi,

There is no way to disable the log right now, but you can use the .NET sound player instead of Notifications.PlaySound method and it will not product any log.

        private static void PlaySound(string path)
        {
            if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException($"'{nameof(path)}' cannot be null or whitespace", nameof(path));

            SoundPlayer soundPlayer = null;

            try
            {
                soundPlayer = new SoundPlayer(path);

                soundPlayer.PlaySync();
            }
            finally
            {
                if (soundPlayer != null) soundPlayer.Dispose();
            }
        }

You have to add "using System.Media" for the above code to work.


@amusleh

Shares4us
20 Mar 2021, 00:08

RE:

amusleh said:

Hi,

There is no way to disable the log right now, but you can use the .NET sound player instead of Notifications.PlaySound method and it will not product any log.

        private static void PlaySound(string path)
        {
            if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException($"'{nameof(path)}' cannot be null or whitespace", nameof(path));

            SoundPlayer soundPlayer = null;

            try
            {
                soundPlayer = new SoundPlayer(path);

                soundPlayer.PlaySync();
            }
            finally
            {
                if (soundPlayer != null) soundPlayer.Dispose();
            }
        }

You have to add "using System.Media" for the above code to work.

Thanks for your time. But i hoped Spotware would change it ;-)


@Shares4us