Announcement

Collapse
No announcement yet.

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().
      DierkNinjaTrader Customer Service

      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.
            DierkNinjaTrader Customer Service

            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 Jeremytang, 07-14-2018, 06:45 PM
                  21 responses
                  439 views
                  0 likes
                  Last Post mav8rick  
                  Started by LeonK, Yesterday, 09:26 PM
                  1 response
                  7 views
                  0 likes
                  Last Post bltdavid  
                  Started by NicholasJoannette, Yesterday, 03:01 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post NicholasJoannette  
                  Started by rach1994, Yesterday, 12:20 PM
                  1 response
                  35 views
                  0 likes
                  Last Post bltdavid  
                  Started by litamm89, Yesterday, 11:00 AM
                  5 responses
                  21 views
                  1 like
                  Last Post rafael_delima86  
                  Working...
                  X