LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop on loop function does not work

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?

Download All
0 Kudos
Message 1 of 7
(3,136 Views)

Keep your while loop inside event and create one extra even for stop. from there try to stoop.

 

Let me know

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 7
(3,133 Views)

@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.

Best regards,

CsabaF
0 Kudos
Message 3 of 7
(3,117 Views)

Something like this - a very basic event structure, just waits for the stop button and updates the indicator with the actual time.

Best regards,

CsabaF
0 Kudos
Message 4 of 7
(3,096 Views)

@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.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 7
(3,094 Views)

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

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 6 of 7
(3,077 Views)

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

Message 7 of 7
(3,043 Views)