I have a URL for playing
https://wortcast01.wortfm.org/appfiles/wort_210715_080006buzzthu.m3u
if I put it to AVPlayer then the item duration equals nan.
var itemDuration: Double? {
return currentItem?.duration.seconds
}
I understand that m3u has a list of items(let's call them tracks)
And AVPlayer knows how to automatically switch from one to another track (in the m3u file).
but, How do I extract the duration of the current playing AVPlayer track(of m3u file)?
Does AVPlayer support .m3u format? (it knows how to play but does not provide info data )
I described the same problem here.
Post
Replies
Boosts
Views
Activity
User flow:
u1. a user starts playing some audio in the app
before playing was set category
try audioSession.setCategory(.playback,
mode: .default,
policy: .longFormAudio)
was activated category
try audioSession.setActive(true, options: [])
set nowPlayingInfo
playing via AVPlayer
u2. user taps on the button of "airplay" (AVRoutePickerView) and changes the route of sound
u3. A user can hear sounds from a Bluetooth column, or connect to an Apple TV with its own audio system...
Issue: On iOS 17, after changing the route to Apple TV, a user can not hear a sound(apple tv works properly but sounds unavailable(if I do the same on iOS 16 everything works correctly)).
AVPlayer works correctly.
in the app I only receive event(name AVAudioSession.routeChangeNotification), and reason: RouteChangeReason.categoryChange (doc description: The audio category has changed (AVAudioSessionCategoryPlayback has been changed to AVAudioSessionCategoryPlayAndRecord).)
Apps capabilities has "Background Mode" = Audio, AirPlay....
Questions:
Does AirPlay require addition configs on iOS 17?(i tried to add in info.plist "AVInitialRouteSharingPolicy = LongformAudio" - this does not help me)
What going on with AVPlayer?(it is playing, but where sound?)
body of notification
Printing description of notification:
▿ name = AVAudioSessionRouteChangeNotification, object = Optional(<AVAudioSession: 0x280089e10>), userInfo = Optional([AnyHashable("AVAudioSessionRouteChangePreviousRouteKey"): <AVAudioSessionRouteDescription: 0x2800a8960,
inputs = (
);
outputs = (
"<AVAudioSessionPortDescription: 0x2800a8300, type = Speaker; name = \U0414\U0438\U043d\U0430\U043c\U0456\U043a; UID = Speaker; selectedDataSource = (null)>"
)>, AnyHashable("AVAudioSessionRouteChangeReasonKey"): 3])
- name : "AVAudioSessionRouteChangeNotification"
- object : <AVAudioSession: 0x280089e10>
▿ userInfo : 2 elements
▿ 0 : 2 elements
▿ key : AnyHashable("AVAudioSessionRouteChangePreviousRouteKey")
- value : "AVAudioSessionRouteChangePreviousRouteKey"
- value : <AVAudioSessionRouteDescription: 0x2800a8960,
inputs = (
);
outputs = (
"<AVAudioSessionPortDescription: 0x2800a8300, type = Speaker; name = \U0414\U0438\U043d\U0430\U043c\U0456\U043a; UID = Speaker; selectedDataSource = (null)>"
)>
▿ 1 : 2 elements
▿ key : AnyHashable("AVAudioSessionRouteChangeReasonKey")
- value : "AVAudioSessionRouteChangeReasonKey"
- value : 3