When connection is cut before track is fully buffered and player reaches end of loaded time ranges, audio stops but status is not updated:
elapsed Time continues to send events
player.timeControlStatus = playing
currentItem!.isPlaybackLikelyToKeepUp = true
player.status = readyToPlay
player.currentItem!.status = readyToPlay
currentItem!.isPlaybackLikelyToKeepUp = true
But an event is logged in errorLog()
"NSURLErrorDomain"
errorStatusCode -1009
This results in weird behaviour where a progress bar is continuing to show progress without any sound. It even continues beyond the total track duration.
Reproducible on demo app https://github.com/timstudt/PlayerApp:
start playback
let buffer til e.g. 70sec (loadedTimeRanges)
activate flight mode
seek to 60sec (returns = successful)
watch:
when player reaches 70sec mark, audio stops, but elapsed time continues.
Note: w/o seeking the player stalls correctly on 70sec mark.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Docs say: "For serial tasks, set the target of your serial queue to one of the global concurrent queues"
but how exactly?
DispatchQueue(label: "", target: .global(qos: .background))
// or
DispatchQueue(label: "", qos: .background, target: .global(qos: .background))
or is it the same?
context:
We use quite a few serial queues in our app. In general each service (e.g. analytics, downloading, etc) has it's own serial queue to sync. access to it's resources.
I have an issue with updating MPNowPlayingInfoCenter when trying to read nowPlayingInfo I don't get a response leading to blocking the current thread indefinitely.
I'm updating MPNowPlayingInfoCenter on main thread which results in an app freeze.
func staticUpdate() {
logger.log(.debug, "start static update")
infoCenter.nowPlayingInfo = nowPlayingInfo
logger.log(.debug, "end static update")
}
func dynamicUpdate() {
logger.log(.debug, "start update - read")
var mpInfo = infoCenter.nowPlayingInfo ?? [String: Any]()
logger.log(.debug, "start update - write")
...
infoCenter.nowPlayingInfo = mpInfo
logger.log(.debug, "end update")
}
/*
2022-04-25 09:28:19.051435+0200 [Debug] [main] [NowPlayingInfoCenterController.swift:128] start static update
2022-04-25 09:28:19.051834+0200 [Debug] [main] [NowPlayingInfoCenterController.swift:130] end static update
2022-04-25 09:28:19.052251+0200 [Debug] [main] [NowPlayingInfoCenterController.swift:186] start update - read
*/
I'm overwriting nowPlayingInfo when media changes, then I'm updating it on any status changes (progress, status,...)
(see timestamps, we read ~1ms after write but never reach infoCenter.nowPlayingInfo = mpInfo)
Questions:
shouldn't infoCenter.nowPlayingInfo always be readable?
can I update infoCenter from any queue? (this would solve only app freeze..)
How can I detect when my app goes from background to suspended state? or better about to be suspended..
AppDelegate has method for entering background and there's even a Notification for this, but I can't find anything about suspended.
And I guess receiveMemoryWarning is not the right one.
the problem is when using HLS live stream with AVPlayer on iOS/ tvOS the player chooses first highest bandwidth then slowly steps down to lowest (within 1-3min) and eventually steps up again then repeats to step down.
the AVPlayer error log sends events:
errorStatusCode: -12888, errorDomain: Optional("CoreMediaErrorDomain"), errorComment: Optional("The operation couldn't be completed. (CoreMediaErrorDomain error -12888 - Playlist File unchanged for longer than 1.5 * target duration
we use standard segments in CMAF format, 2sec duration
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:147065903
#EXT-X-MAP:URI="video_1_4660000_init.mp4?device_profile=cmaf_cbcs_verimatrix_cei%26seg_size=2%26cmaf=2"
#EXT-X-PROGRAM-DATE-TIME:2025-04-30T12:51:07
#EXTINF:2.000,
video_1_4660000_t17460174670001555.mp4?device_profile=cmaf_cbcs_verimatrix_cei%26seg_size=2%26cmaf=2
#EXTINF:2.000,
video_1_4660000_t17460174690001555.mp4?device_profile=cmaf_cbcs_verimatrix_cei%26seg_size=2%26cmaf=2
#EXTINF:2.000,
video_1_4660000_t17460174710001555.mp4?device_profile=cmaf_cbcs_verimatrix_cei%26seg_size=2%26cmaf=2
when using 6sec segments the player stays stable at highest bandwidth.
is there a way to avoid this error? in AVPlayer or HLS configuration?
quotes are displayed incorrectly in subtitles of AVPlayerViewController when streaming VOD content using HLS.
single quote ' (escaped ') is displayed as apos;
double quotes " (escaped ") is displayed as quot;
following the vtt specification.
The same stream works fine in VLC player, showing quotes correctly in subtitles.
subtitle vtt files use
Content-Type: text/vtt
WEBVTT
X-TIMESTAMP-MAP=LOCAL:490014:06:04.000,MPEGTS:158764568760056
example line:
490014:05:46.000 --> 490014:05:50.440 align:start line:83% position:14%
and the playlist has:
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",LANGUAGE="da",NAME="Dansk",AUTOSELECT=YES,CHARACTERISTICS="public.accessibility.transcribes-spoken-dialog,public.accessibility.describes-music-and-sound",URI="subs/dan_5/playlist.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=780000,CODECS="mp4a.40.5,avc1.42c01e",RESOLUTION=256x144,AUDIO="audio-aac",SUBTITLES="subs"
lære dig endnu bedre at kende."
adding 'wvtt' to CODECS list in playlist does not make a difference.
Is this a known bug? Is there a workaround?
I guess the AVResourceLoaderDelegate can be used to intercept and parse the subtitle files, but it seems like quite a hack and not really intended to be used for this.