Swiftpack.co -  boring-wozniak/AudioDeviceUtil as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Change playback device without pain
.package(url: "https://github.com/boring-wozniak/AudioDeviceUtil.git", from: "0.0.3")



// In your Package.swift
.package(url: "https://github.com/boring-wozniak/AudioDeviceUtil", from: "0.0.3"),

Usage Example

import AppKit
import AudioObjectUtil

let path = "/path/to/the/sound/you/want/to/play"
guard let sound = NSSound(contentsOfFile: path, byReference: true) else {
    fatalError("Failed to create an NSSound object with file path '\(path)'")

let deviceName = "As shown in Sound Preferences"
guard let deviceUID = try findDeviceUIDBy(name: deviceName) else {
    fatalError("Cannot find a device with name '\(deviceName)'")

// This is exactly what this library is about :)
// See https://stackoverflow.com/q/1983984 for more
sound.playbackDeviceIdentifier = deviceUID

if !sound.play() {
    fatalError("Cannot play the sound")

// Wait until the playback finishes

My grandma would write it better...🤬

Please, open the issue and describe briefly what exactly is looking troublesome in the code, ideally, with links, references, etc... This is my first gig on the Swift territory so feedback from more experienced developers is very appreciated


Stars: 1
Last commit: 1 year ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API