2023-11-27 00:52:17 -05:00
from collections . abc import Callable
2023-12-05 21:54:40 -05:00
from typing import Final , Literal , override
2023-11-27 00:52:17 -05:00
from AppKit import NSImage
from Foundation import CGSize , NSMutableDictionary
MPMusicPlaybackStateStopped : Final = 0
MPMusicPlaybackStatePlaying : Final = 1
MPMusicPlaybackStatePaused : Final = 2
MPMusicPlaybackState = Literal [ 0 , 1 , 2 ]
2023-12-05 19:51:29 -05:00
MPMediaItemPropertyAlbumTitle : Final = " albumTitle "
MPMediaItemPropertyAlbumTrackNumber : Final = " albumTrackNumber "
MPMediaItemPropertyDiscNumber : Final = " discNumber "
MPMediaItemPropertyGenre : Final = " genre "
MPMediaItemPropertyArtist : Final = " artist "
MPMediaItemPropertyComposer : Final = " composer "
MPMediaItemPropertyArtwork : Final = " artwork "
MPMediaItemPropertyPlaybackDuration : Final = " playbackDuration "
MPMediaItemPropertyPersistentID : Final = " persistentID "
MPMediaItemPropertyTitle : Final = " title "
2023-11-27 00:52:17 -05:00
2023-12-05 19:51:29 -05:00
MPNowPlayingInfoPropertyMediaType : Final = " MPNowPlayingInfoPropertyMediaType "
2023-11-27 00:52:17 -05:00
MPNowPlayingInfoMediaTypeAudio : Final = 1
MPNowPlayingInfoMediaTypeNone : Final = 0
2023-12-05 20:02:13 -05:00
MPNowPlayingInfoPropertyPlaybackRate : Final = " MPNowPlayingInfoPropertyPlaybackRate "
2023-12-05 19:51:29 -05:00
MPNowPlayingInfoPropertyPlaybackQueueCount : Final = (
" MPNowPlayingInfoPropertyPlaybackQueueCount "
)
MPNowPlayingInfoPropertyPlaybackQueueIndex : Final = (
" MPNowPlayingInfoPropertyPlaybackQueueIndex "
)
MPNowPlayingInfoPropertyElapsedPlaybackTime : Final = (
" MPNowPlayingInfoPropertyElapsedPlaybackTime "
)
MPNowPlayingInfoPropertyExternalContentIdentifier : Final = (
" MPNowPlayingInfoPropertyExternalContentIdentifier "
)
2023-11-27 00:52:17 -05:00
class MPMediaItemArtwork :
2023-12-05 19:51:29 -05:00
@staticmethod
def alloc ( ) - > type [ MPMediaItemArtwork ] : . . .
@staticmethod
def initWithBoundsSize_requestHandler_ (
size : CGSize , handler : Callable [ [ CGSize ] , NSImage ]
) - > MPMediaItemArtwork : . . .
2023-11-27 00:52:17 -05:00
class MPNowPlayingInfoCenter :
2023-12-05 19:51:29 -05:00
@staticmethod
def defaultCenter ( ) - > MPNowPlayingInfoCenter : . . .
def setNowPlayingInfo_ ( self , info : NSMutableDictionary ) - > None : . . .
def setPlaybackState_ ( self , state : MPMusicPlaybackState ) - > None : . . .
2023-11-27 00:52:17 -05:00
2023-12-05 21:54:40 -05:00
MPRemoteCommandHandlerStatusSuccess : Final = 0
MPRemoteCommandHandlerStatusCommandFailed : Final = 200
2023-11-27 00:52:17 -05:00
MPRemoteCommandHandlerStatus = Literal [ 0 , 200 ]
class MPRemoteCommandEvent :
2023-12-05 19:51:29 -05:00
pass
2023-11-27 00:52:17 -05:00
2023-12-05 21:54:40 -05:00
class MPChangePlaybackPositionCommandEvent ( MPRemoteCommandEvent ) :
def positionTime ( self ) - > float :
""" Return the requested playback position as a number of seconds (fractional seconds are allowed). """
pass
2023-11-27 00:52:17 -05:00
class MPRemoteCommand :
2023-12-05 19:51:29 -05:00
def setEnabled_ ( self , enabled : bool ) - > None : . . .
def removeTarget_ ( self , target : object ) - > None : . . .
def addTargetWithHandler_ (
self , handler : Callable [ [ MPRemoteCommandEvent ] , MPRemoteCommandHandlerStatus ]
2023-12-05 21:54:40 -05:00
) - > None :
""" Register a callback to handle the commands. Many remote commands don ' t carry useful information in the event object (play, pause, next track, etc.), so the callback does not necessarily need to care about the event argument. """
pass
class MPChangePlaybackPositionCommand ( MPRemoteCommand ) :
@override
def addTargetWithHandler_ (
self ,
handler : Callable [
[ MPChangePlaybackPositionCommandEvent ] , MPRemoteCommandHandlerStatus
] ,
2023-12-05 19:51:29 -05:00
) - > None : . . .
2023-11-27 00:52:17 -05:00
class MPRemoteCommandCenter :
2023-12-05 19:51:29 -05:00
@staticmethod
def sharedCommandCenter ( ) - > MPRemoteCommandCenter : . . .
def togglePlayPauseCommand ( self ) - > MPRemoteCommand : . . .
def playCommand ( self ) - > MPRemoteCommand : . . .
def pauseCommand ( self ) - > MPRemoteCommand : . . .
def stopCommand ( self ) - > MPRemoteCommand : . . .
def nextTrackCommand ( self ) - > MPRemoteCommand : . . .
def previousTrackCommand ( self ) - > MPRemoteCommand : . . .
def changePlaybackRateCommand ( self ) - > MPRemoteCommand : . . .
def seekBackwardCommand ( self ) - > MPRemoteCommand : . . .
def skipBackwardCommand ( self ) - > MPRemoteCommand : . . .
def seekForwardCommand ( self ) - > MPRemoteCommand : . . .
def skipForwardCommand ( self ) - > MPRemoteCommand : . . .
2023-12-05 21:54:40 -05:00
def changePlaybackPositionCommand ( self ) - > MPChangePlaybackPositionCommand : . . .