use float value from OS seek
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
|||||||
// os_remote_command_callback is called by Objective-C when incoming OS media commands are received.
|
// os_remote_command_callback is called by Objective-C when incoming OS media commands are received.
|
||||||
//
|
//
|
||||||
//export os_remote_command_callback
|
//export os_remote_command_callback
|
||||||
func os_remote_command_callback(command C.Command, value C.int) {
|
func os_remote_command_callback(command C.Command, value C.double) {
|
||||||
switch command {
|
switch command {
|
||||||
case C.PLAY:
|
case C.PLAY:
|
||||||
mpMediaEventRecipient.OnCommandPlay()
|
mpMediaEventRecipient.OnCommandPlay()
|
||||||
@@ -42,7 +42,7 @@ func os_remote_command_callback(command C.Command, value C.int) {
|
|||||||
case C.NEXT_TRACK:
|
case C.NEXT_TRACK:
|
||||||
mpMediaEventRecipient.OnCommandNextTrack()
|
mpMediaEventRecipient.OnCommandNextTrack()
|
||||||
case C.SEEK:
|
case C.SEEK:
|
||||||
mpMediaEventRecipient.OnCommandSeek(int(value))
|
mpMediaEventRecipient.OnCommandSeek(float64(value))
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown OS command received: %v", command)
|
log.Printf("unknown OS command received: %v", command)
|
||||||
}
|
}
|
||||||
@@ -172,9 +172,9 @@ func (mp *MPMediaHandler) OnCommandPreviousTrack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MPMediaHandler instance received OS command to 'seek'
|
// MPMediaHandler instance received OS command to 'seek'
|
||||||
func (mp *MPMediaHandler) OnCommandSeek(positionSeconds int) {
|
func (mp *MPMediaHandler) OnCommandSeek(positionSeconds float64) {
|
||||||
if mp == nil || mp.player == nil {
|
if mp == nil || mp.player == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
mp.player.Seek(fmt.Sprintf("%d", positionSeconds), player.SeekAbsolute)
|
mp.player.Seek(fmt.Sprintf("%0.2f", positionSeconds), player.SeekAbsolute)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ void register_os_remote_commands();
|
|||||||
* Go-backed callback to static function that is called when OS remote commands are received.
|
* Go-backed callback to static function that is called when OS remote commands are received.
|
||||||
* If a value is anticipated with the specified command, the 'value' argument will be non-zero.
|
* If a value is anticipated with the specified command, the 'value' argument will be non-zero.
|
||||||
*/
|
*/
|
||||||
void os_remote_command_callback(Command command, int value);
|
void os_remote_command_callback(Command command, double value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the "Now Playing" information on macOS for media playback
|
* Updates the "Now Playing" information on macOS for media playback
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ void register_os_remote_commands() {
|
|||||||
|
|
||||||
[commandCenter.changePlaybackPositionCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
|
[commandCenter.changePlaybackPositionCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
|
||||||
MPChangePlaybackPositionCommandEvent *positionChangeEvent = (MPChangePlaybackPositionCommandEvent *)event;
|
MPChangePlaybackPositionCommandEvent *positionChangeEvent = (MPChangePlaybackPositionCommandEvent *)event;
|
||||||
double posSecDouble = positionChangeEvent.positionTime;
|
os_remote_command_callback(SEEK, positionChangeEvent.positionTime);
|
||||||
int posSeconds = (int)posSecDouble;
|
|
||||||
os_remote_command_callback(SEEK, posSeconds);
|
|
||||||
return MPRemoteCommandHandlerStatusSuccess;
|
return MPRemoteCommandHandlerStatusSuccess;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user