The NSSound class provides a simple interface for loading and playing audio files. This class supports the same audio encodings and file formats that are supported by Core Audio and QuickTime.
Questions tagged [nssound]
39 questions
1
vote
0 answers
NSSound strange bug
This code plays the sound:
NSSound *sound = [[NSSound alloc] initWithContentsOfFile:@"/Users/alex/test.ogg"
byReference:NO];
[sound play];
This code does not:
NSData *song = [testingResultsData…

Alex
- 393
- 6
- 21
1
vote
2 answers
Objective C : Misunderstanding with the didFinishPLaying delegate method
I want to get familiar with the Objective C/Interface Builder programming on mac OSX. I'm usually working with sounds, so I'm trying to code a simple audio player, using the NSSound class.
I already managed to create a basic application that loads a…

Sirdouille
- 11
- 2
1
vote
3 answers
NSSound-like framework that works, but doesn't require dealing with a steep learning curve
I've pretty much finished work on a white noise feature for one of my applications using NSSound to play a loop of 10 second AAC-encoded pre-recorded white noise.
[sound setLoops: YES]
should be all that's required, right?
It works like a charm but…

Frank R.
- 2,328
- 1
- 24
- 44
1
vote
1 answer
How Do I check if NSSound is paused in Swift
I am able to play a sound in swift with NSSound:
var path ="/path/to/file.mp3"
mysound = NSSound(contentsOfFile: path, byReference: false)
mysound!.play() // works!
if (mysound!playing)
{
mysound!.pause() //works, sort of
}
mysound!playing //…

basementjack
- 566
- 1
- 7
- 19
1
vote
2 answers
Swift NSSound plays silently?
I've done a bit of Swift and a fair amount of Objective-C on iOS, but basically no real OS X programming, so I haven't used NSSound. I was trying to help someone on a Swift forum, and ... it's not working. I'm not sure why.
In a playground, Swift…

Geoffrey Wiseman
- 5,459
- 3
- 34
- 52
1
vote
2 answers
Counting number of times an NSSound loops (Swift)
As the title suggests, I'm trying to figure out how to count the number of times an NSSound loops (or, more accurately, have a function run at the beginning and/or end of each loop). I've looked at all the documentation, but I can't find anything.…

Matt
- 2,576
- 6
- 34
- 52
1
vote
1 answer
Can't find sound played when an item is dragged
I am trying to search that sound that is played when you drag an item to a finder window. I searched in /System/Library/Sounds and I've found these:
Basso.aiff
Blow.aiff
Bottle.aiff
Frog.aiff
Funk.aiff
Glass.aiff
Hero.aiff
…

Ramy Al Zuhouri
- 21,580
- 26
- 105
- 187
1
vote
1 answer
Unable to put NSSound instance in NSMutableArray ion cocoa
I'm having trouble adding NSsound instances into an NSMutableArray
The error I get is that I cannot do [soundFiles addObject:soundObj], because soundObj is nil. But if I do [soundObj play], it will play - so it is an instance.
//Name of all the…

Adam Meyer
- 1,505
- 1
- 19
- 28
1
vote
2 answers
How to play a mp3 file from within the Resources folder of my application?
I am making an app that will play sound on events but I can't figure out how to access files from the ressources folder of the Application.
Here is what I'm doing :
NSSound *player = [[NSSound alloc] initWithContentsOfFile:@"Sound.mp3"]…

Fantattitude
- 1,842
- 2
- 18
- 34
0
votes
3 answers
NSSound isPlaying returning null on Mac
In my AppDelegate I have this method which will run when the play button is clicked:
- (IBAction)actionPlayTrack:(id)sender {
NSSound *currentSong = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"03 Bazel"…

Scott Nicol
- 11,458
- 3
- 15
- 8
0
votes
1 answer
How repeat sound of local notification until any button of alert view is not pressed?
I have an alarm clock in which i have set a local notification on user set data. Now when local notification generate then an alert view appear and a sound also played. But sound play for 2 seconds while i required that while not pressed any button…

ios
- 552
- 5
- 22
0
votes
1 answer
NSSound audible clicks on loop
I have an NSSound that is looping, and every time it loops there is an audible 'click' sound when it replays.
I'm using these methods:
[sound play];
[sound setLoops:YES];
Is there any way to get rid of this click? I have tried to alter the wav file…

Moonlight293
- 197
- 1
- 5
- 13
0
votes
2 answers
Using python, how do I construct a delegate for the macOS sound player NSSound?
I am writing a music database manager using python and tkinter. It is nearly all complete but I am stuck on playing songs from a list. The native macOS player NSSound has a built-in callback to a delegate which signals the end of the track so I…

user10850186
- 1
- 2
0
votes
2 answers
NSSound.beep() isn't working in macOs (Swift)
I'm trying to do a an status item with a single button that sounds a beep when pressed.
But nothing is playing when pressing.
This is the code:
import SwiftUI
import AppKit
struct MenuView: View {
@State var currentTab = "Enabled"
var…

Rjuanez
- 5
- 1
0
votes
1 answer
NSSound stop function
Thanks for the help.
This activates basic playback of referenced file:
NSSound *sound = [[NSSound alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ping" ofType:@"aiff"] byReference:NO];
[sound play];
What's the proper way to…

Paul
- 189
- 10