[futurebasic] Re: [FB] How do we determine when NSSound is paused?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2017 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 26 Apr 2017 22:36:23 -0400
Steve wrote:

> I understand that the method has to have been called at some time in order to have a result, but what if I want to know what the result was the last time through, and don't want to call the method again because it will interfere with something else that I'm trying to do?  I think a variable would be more appropriate in this situation.


Take a look at the NSSound docs -- pause and resume each return a Boolean value depending upon their current state.

Below is a little example of how you can test them.

In this code we load and start the sound but immediately pause it, and test the state of pause. Then we let the system sleep three seconds, resume play and test its state.

I used a system sound, but a longer sound file would make the results more impressive.

Ken

include "NSLog.incl"

BeginCCode
BOOL isPaused, isResumed;
NSSound *snd = [NSSound soundNamed:@"Submarine"];
[snd play];
isPaused = [snd pause];
NSLog(@"isPaused = %@", (isPaused ? @"YES" : @"NO"));
sleep(3);
isResumed = [snd resume];
NSLog(@"isResumed = %@", (isResumed ? @"YES" : @"NO"));
NSLog(@"Playing now.");
[snd play];
EndC

RunApplicationEventLoop()