11-18-2014 01:47 AM
My stop button for this program is not working.
I want the .wav file to stop playing when I press the STOP button.
How do I accomplish this?
I have attached the picture and the .vi of the program. Can someone explain why the stop button is not working?
11-18-2014 01:52 AM
Keep your while loop inside event and create one extra even for stop. from there try to stoop.
Let me know
11-18-2014 02:03 AM - edited 11-18-2014 02:06 AM
@flyingpants88 wrote:
My stop button for this program is not working.
I want the .wav file to stop playing when I press the STOP button.
How do I accomplish this?
I have attached the picture and the .vi of the program. Can someone explain why the stop button is not working?
I think you misunderstood the event structure concept. Try to take a look on this Youtube tutorial http://youtu.be/8eO64fo3Pho and on the LabVIEW help http://zone.ni.com/reference/en-XX/help/371361K-01/glang/event_structure/
You need at least one more loop outside your event structure. The event structure will handle your events, for example start/stop playback and stop execution. Create one event for each action.
I would recommend to start with a very simple event structure handler, just to understand the concept: wait for the stop button and shut down the app.
11-18-2014 02:18 AM
Something like this - a very basic event structure, just waits for the stop button and updates the indicator with the actual time.
11-18-2014 02:22 AM
@Ranjeet_Singh wrote:
Keep your while loop inside event and create one extra even for stop. from there try to stoop.
Let me know
Are you sure? Is this a typo by chance?
As suggested you have to understand the use of Event structure and keeping a while loop inside an event structure is really a bad idea.
Good set of materials available here in this Intro page by Hooovahh.
11-18-2014 03:51 AM
P@Anand wrote:
@Ranjeet_Singh wrote:
Keep your while loop inside event and create one extra even for stop. from there try to stoop.
Let me know
Are you sure? Is this a typo by chance?
As suggested you have to understand the use of Event structure and keeping a while loop inside an event structure is really a bad idea.
Good set of materials available here in this Intro page by Hooovahh.
sorry. I said wrong. Always we need to keep while loop outside only. Big mistake
11-18-2014 12:21 PM
While these posts have pointed out some flaws in your program, none have addressed the question you posed of how to stop the playing when pressing the STOP button.
There are two issues related to that. First is basic dataflow. The loop cannot stop until all the code inside the loop has completed executing. So, regardless of the state of the stop button, Play Sound File.vi must complete. Then Sound Output Info.vi must complete. Then Sound Output Clear.vi must complete. Because the stop button executes in parallel to the sound VIs, it almost certainly will have been read within a few nanoseconds after the loop iteration started and will not be read again until the next iteration starts. So one extra iteration will take place before the loop stops in most cases.
Read the detailed help for Play Sound File.vi. I think you want to set the timeout to zero. Then Sound Output Info.vi and the stop button should be in a loop with a short Wait - perhaps about 100 ms. Stop that loop when is playing? is False or stop is True. Then call Sound Output Clear.vi.
Lynn