none
Stoping playback in middle of the file. RRS feed

  • Question

  • Hello

    Everyone, this is my first post in the forum.

    I'm developing a pseudo-KinectStudio app that plays every .XEF file listed in a textfile. It does play fine until the second file.

    When the second file is being played suddenly it stops, without no reason. 

    The code is the following:

    private void Play() {
    
                using (KStudioClient client = KStudio.CreateClient())
                {
    
    
                    client.ConnectToService();
    
    
                    for (int f = 0; f < fileNames.Length; f++)
                    {
    
    
                        string[] nameAndLoop = fileNames[f].Split(',');
                        Dispatcher.InvokeAsync(new Action(() => this.statusBox.Text = "Playing" + nameAndLoop[0]));
    
                        double loopCount = 0, timeSleept = 0;
    
                        try
                        {
                            playback = client.CreatePlayback(nameAndLoop[0]);
                            if (nameAndLoop.Length > 1)
                            {
                                loopCount = Double.Parse(nameAndLoop[1]);
                            }
                            else
                                loopCount = 1;
    
    
                            playback.LoopCount = (uint)loopCount;
                            playback.EndBehavior = KStudioPlaybackEndBehavior.Stop;
                            playback.Start();
    
                            while (playback.State == KStudioPlaybackState.Playing)
                            {
                                Thread.Sleep(100);
                                timeSleept += 100;
                            }
    
                            if (playback.State == KStudioPlaybackState.Stopped && timeSleept < playback.Duration.TotalMilliseconds * loopCount)
                            {
                                Console.WriteLine("It is stopped prematurely");
                                f -= 1;
                            }
    
                        }
                        catch (ArgumentException a)
                        {
                            Console.Write(a.ToString());
                            Application.Current.Shutdown();
                        }
    
    
                    }
    
    
                }

    It displays the "It's stops prematurely".

    Play function is called when a button is pressed. In fact, the button event handler creates a Thread that executes Play function.

    Program configuration:

    Debug, x64.

    Systems:

    Windows 10 Creators Update,

    Does anyone have the same problem ?  Does anyone find a solution?

    Github repo: https://github.com/LauraLaureus/KinectPlay

    Friday, June 2, 2017 9:08 AM