Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Playing 2 sound files sequentially

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Playing 2 sound files sequentially

    How to play 2 sound files sequentially ?

    I tried with Alert() and PlaySound() with no luck. I can only hear the last sound file.

    Basically what I want to do is Play/Alert 1st sound file and after it finishes, it then Play/Alert 2nd sound file.

    #2
    You would have to code your own way to play sounds files using C# language and play them synchronously. NT methods are asynchronous.
    RayNinjaTrader Customer Service

    Comment


      #3
      To clarify: Ray's recommendation comes at the expense that NT would be locked up (=non responsive) if you played sound files synchronously. That's why NinjaScript plays it asynchronously.

      A different approach would be recording the sound files as one and play that by PlaySound().

      Comment


        #4
        Thanks for the hint, I am going after playing C# first, because combination will create lots of files.

        But, it would be great to have option to choose between synch and asynch.

        Comment


          #5
          This is what I do, the keyword would be PlaySync.

          using System.Media;
          using System.IO;

          private SoundPlayer player = new SoundPlayer();
          private string directory;

          directory = Directory.GetParent(Environment.CurrentDirectory). FullName + "\\sounds\\";

          player.SoundLocation = directory+"sound.wav";
          player.PlaySync();

          Comment


            #6
            Again: we recommend NOT doing that, since it will lock up NT while the sound file it played. That's why we won't provide an option to play sound files synchronized.

            Comment


              #7
              Yes, I can see that how the performance degrades, but I keep my sound files very small and very short, also I only use this for the 1st sound file, the 2nd sound file is still using Alert and it only triggers every 20 seconds.

              Comment


                #8
                Originally posted by NinjaTrader_Dierk View Post
                Again: we recommend NOT doing that, since it will lock up NT while the sound file it played. That's why we won't provide an option to play sound files synchronized.
                Is there sample code for playing a sound file asynchronously?

                Comment


                  #9
                  We do not have one.
                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bmartz, 03-12-2024, 06:12 AM
                  2 responses
                  19 views
                  0 likes
                  Last Post bmartz
                  by bmartz
                   
                  Started by funk10101, Today, 12:02 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post funk10101  
                  Started by gravdigaz6, Yesterday, 11:40 PM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by MarianApalaghiei, Yesterday, 10:49 PM
                  3 responses
                  10 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by XXtrader, Yesterday, 11:30 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post XXtrader  
                  Working...
                  X