Notifications.PlaySound not working

Created at 10 Feb 2023, 15:10
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!
WM

wmclennan77

Joined 29.06.2021

Notifications.PlaySound not working
10 Feb 2023, 15:10


Hi,

I am testing the Notifications.PlaySound and cannot get the sounds to play. Am I using the method wrong or something>?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }
        
        readonly string SoundFilePath = "C:/Users/username/Documents/cTrader/Sounds/EntryNotification.mp3";

        protected override void OnStart()
        {
            //
        }

        protected override void OnBar()
        {
            Notifications.PlaySound(SoundFilePath);
        }
    }
}

 


@wmclennan77
Replies

PanagiotisChar
10 Feb 2023, 16:11

Hi there,

Check your log in case there are any exceptions thrown.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar

nh.zadeh
04 Mar 2023, 18:31 ( Updated at: 04 Mar 2023, 18:32 )

RE:

wmclennan77 said:

Hi,

I am testing the Notifications.PlaySound and cannot get the sounds to play. Am I using the method wrong or something>?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }
        
        readonly string SoundFilePath = "C:/Users/username/Documents/cTrader/Sounds/EntryNotification.mp3";

        protected override void OnStart()
        {
            //
        }

        protected override void OnBar()
        {
            Notifications.PlaySound(SoundFilePath);
        }
    }
}

 

just add @ in following:

readonly string SoundFilePath = @"C:/Users/username/Documents/cTrader/Sounds/EntryNotification.mp3";\

or use double / (//) rathar than one / 


@nh.zadeh