MusicKit swift start / end times

Hello!

I am having trouble setting start times for songs when using the ApplicationMusicPlayer.

When I initialize a new MusicPlayer.Queue.Entry using the following constructor, I am seeing strange results:

init(
    _ playableMusicItem: PlayableMusicItem,
    startTime: TimeInterval? = nil,
    endTime: TimeInterval? = nil
)

It appears that any value I provide for startTime is also applied to the endTime. For example:

MusicPlayer.Queue.Entry(playable, startTime: TimeInterval(30), endTime: TimeInterval(183))

provides the following console output:

MusicPlayer.Queue.Entry(id: "3D6A3DA3-595E-4657-8DBA-DDD245BBB7EF", transientItem: PlayableMusicItem, startTime: 30.0, endTime: 30.0)

I have also tried setting the endTime to nil with the same result. Does anyone have any experience setting start times for songs using the MusicKit ApplicationMusicPlayer?

Any feedback is greatly appreciated!

I am seeing the same thing. Any update on this?

This issue is making our use of MusicKit a lot more complex than it needs to be. This is clearly a bug. Would be good to have someone from Apple weigh in here.

This is the same behavior for me; it does skip the song to the start time, but it does not play anymore.

Here is the code:

let entry = MusicPlayer.Queue.Entry(self.track!, startTime: TimeInterval(song.startTime ?? 0), endTime: nil)
                        
self.musicPlayer.queue =  MusicPlayer.Queue([entry])
                        
try? await self.musicPlayer.prepareToPlay()
try? await self.musicPlayer.play()

Bump! I'm having the same issue. I've tried countless variations of this, but they all suffer from the same issue.

This also affects the play button in the apple music app, after attempting to set the queue with an entry that has a defined startTime, the play button changes the player state as follows.

LOG  New Playback State: {"playbackStatus": "paused", "playbackTime": 20, "title": "Tangerine"} 
LOG  New Playback State: {"playbackStatus": "playing", "playbackTime": 20.000288009643555, "title": "Tangerine"} 
LOG  New Playback State: {"playbackStatus": "stopped", "playbackTime": 20.000307083129883, "title": "Tangerine"} 
LOG  New Playback State: {"playbackStatus": "paused", "playbackTime": 20, "title": "Tangerine"} 

The Code

let musicItemId = MusicItemID.init(itemId)
let request = MusicCatalogResourceRequest<Song>(matching: \.id, equalTo: musicItemId)
let response = try await request.response()
let player = SystemMusicPlayer.shared
guard let playableMusicItem = response.items.first else { return }
let queueEntry = MusicPlayer.Queue.Entry(playableMusicItem, startTime: 25.0, endTime: 35.0)
let queue = MusicPlayer.Queue.init([queueEntry])
            
player.queue = queue

try await player.prepareToPlay()

Hello everyone, did anyone get past this issue? We're having the same issues. After countless tries, we have set the start time but we can't play the song then.

We have also observed that when we set up a song to start at let's say 30 seconds, it will not go further than that value even if you close the app and play directly from the Apple Music app.

MusicKit swift start / end times
 
 
Q