Giter VIP home page Giter VIP logo

Comments (3)

hhas avatar hhas commented on May 30, 2024

You could check what Distributed Notifications Music.app emits, e.g. I know it sends notifications of track changes, and if there’s one for volume changes then register a listener with DistributedNotificationCenter for that.

Chances are it doesn’t (DNs are cool but massively undersupported and underused), in which case all you can do is actively poll. Run a repeating Timer in your app that periodically (e.g. every 200ms) sends Music.app a get volume Apple event and updates your GUI with the result of that.

from swift-applescriptobjc.

tcarroll2 avatar tcarroll2 commented on May 30, 2024

Roger that. I will have to look to see, but similar to your thoughts it is probably a longshot. I will certainly do the timer thing to poll the volume if a DN doesn't exist. Thank you for putting this out there!

from swift-applescriptobjc.

tcarroll2 avatar tcarroll2 commented on May 30, 2024

My intention with this was to implement a background music option for when the main app is not playing music, so I dug around and tried implementing a couple items like get current playlist and set playlist, but I couldn't get this to work. I was getting a lot of errors, so I decided AppleScript is for AppleScripters and Swift is for Swifters and I just implemented a background player in my app that I can set a playlist and play/pause as I needed when my app is not playing the main music. It also helps to not to have to rely on sandboxing, hardened runtime, and other permissions, or opening Music in the background. It's all contained in my app.

Again, thanks for sharing this and opening my mind to other possibilities and options.

from swift-applescriptobjc.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.