Create view-level services for media playback, complete with user controls, chapter navigation, and support for subtitles and closed captioning using AVKit.

Posts under AVKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

RAW photos display as if overexposed in iOS Photos and MacOS Preview
When capturing RAW (not ProRAW) photos using AVCapturePhotoOutput, the resulting images are subject to a strange overexposed effect when viewed in Apple software. I have been able to recreate this in multiple iOS apps which allow RAW capture. Some users report previously normal images transforming over the span of a few minutes. I have actually watched this happen in real-time: if you observe the camera roll after taking a few RAW photos, the highlights in some will randomly **** (edit: this just says b l o w, nice job profanity filter) out of proportion after whatever is causing this issue kicks in. The issue can also be triggered by zooming in to one of these images from the stock Photos app. Once the overexposure happens on a given image, there doesn't appear to be a way to get it to display normally again. However, if you AirDrop an image to a different device and then back, you can see it display normally at first and then break once more. Interestingly, the photo displays completely fine when viewed in Affinity photo or random photo viewers on Ubuntu. Sometimes the issue is not that bad, but it is often egregious, resulting in completely white areas of a previously balanced photo (see https://discussions.apple.com/thread/254424489). This definitely seems like a bug, but is there any way to prevent it? Could there be an issue with color profiles? This is not the same issue in which users think RAW photos are broken because they are viewing the associated JPG – this happens even with photos that have no embedded JPG or HEIC preview. Very similar (supposedly fixed) issue on MacOS: https://www.macworld.com/article/1444389/overexposed-raw-image-export-macos-monterey-photos-fixed.html Numerous similar complaints: https://discussions.apple.com/thread/254424489 https://discussions.apple.com/thread/253179308 https://discussions.apple.com/thread/253773180 https://discussions.apple.com/thread/253954972 https://discussions.apple.com/thread/252354516
3
3
3.9k
Jun ’23
import AVKit - no such module on TVOS, possible for ios/multiplatform
When starting a new TVOS project and try to import AVKit it says no such module available. I added them on Frameworks, Libraries and Content - still nothing. Double checked if they are in BuildPhases - Link Binary with LibrariesBuild Phases Cleaned build folder and Derived Data. Nothing Worked. According to Apple's documentation it is supposed to be available for TVOS, but i simply cannot get it to be available. When I start a new multiplatform or iOS project it is possible to import it, just not for TVOS, don't know what to do.Didn't have to add any framework manually, simply worked. No issues when starting a new ios project Project settings iOS. What's going on here?
3
0
2.1k
Jun ’23
pip not working in iOS 14
I implemented a custom player and used AVPictureInPictureController. pip button is coming and also calling startPictureInPicture() in action. controller.isPictureInPicturePossible is returning true. AVPictureInPictureController delegates are not receiving the call. Any help? func pictureInPictureControllerWillStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {     print("PIP will start") } Have enabled Picture in picture in background mode capability set AVAudioSession category to playback in appdelegate set AVAudioSession.sharedInstance().setActive(true) as true
1
0
1.6k
Jun ’23
Can I use AVPlayerViewController with AVPlayerLooper?
I want to use AVPlayerViewController to display the video but it should be in auto-play mode. Previously I was using AVPlayer for that and listening to the .AVPlayerItemDidPlayToEndTime notification but I wonder if there is a better way? eg. using AVPlayerLooper for instance so I don't have to use that .AVPlayerItemDidPlayToEndTime anymore I wrote something like this but it is not working - I have a black screen with video controls - probably because AVPlayerViewController does not have any playable content... struct VideoPlayerQueuedView: UIViewControllerRepresentable { let videoUrl: URL func makeUIViewController(context: Context) -> AVPlayerViewController { let queuePlayer = AVQueuePlayer() let playerViewController = AVPlayerViewController() // Create an AVPlayerItem from the videoUrl let playerItem = AVPlayerItem(url: videoUrl) // Create an AVPlayerLooper with the queuePlayer and the playerItem as the template item let playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: playerItem) // Set the player property of AVPlayerViewController playerViewController.player = queuePlayer return playerViewController } func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) { // Update the video player if needed } }
0
0
994
Jun ’23
Why AVPlayer returns video duration (seconds) as Double?
I need to get video duration in seconds. If I use code below guard let playerItem = self.player?.currentItem else { return 0 } print("playerItem.duration", playerItem.duration, playerItem.duration.seconds, playerItem.duration.toString) it returns me a double value 37.568 CMTime(value: 37568, timescale: 1000, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0) 37.568 00:00:37 I wonder why it's a 37.568 instead of 37.000? if video is 00:00:37? Does it means, it is a 37,5s long?
2
0
1.3k
May ’23
AVPlayer video track freeze after 1 second while audio continues
Hi, In my SwiftUI app, I'm using AVPlayer and a UIViewRepresentable view to play back a video from a network server. There are many videos on the server, so I have a LazyHStack for the video thumbnails. Only one video is shown on screen at a time. When the user scrolls between videos, I will create a new AVPlayerItem and replace the current player item in the AVPlayer. The problem is: the first video plays back without any problems. But when the user scrolls over to the next video, the new video would play for 1 second and then freezes while the audio track continues. The video track would resume after a few seconds. One note is that if I drag the video view a bit without fully scrolling to another video, the video track will resume after I released the drag. So it seems maybe somehow the AVPlayerLayer was not rendering? Related code pieces: struct PlayerView: UIViewRepresentable { let player: Player let width: CGFloat let height: CGFloat @Binding var updateCount: Int func makeUIView(context: Context) -> UIView { print("\(#function)") let playerLayer = AVPlayerLayer(player: player) let view = UIView() view.frame = CGRectMake(0, 0, width, height) playerLayer.frame = view.bounds view.layer.addSublayer(playerLayer) return view } func updateUIView(_ uiView: UIView, context: Context) { print("\(#function)") guard let playerLayer = uiView.layer.sublayers?.first as? AVPlayerLayer else { return } uiView.frame = CGRectMake(0, 0, width, height) if updateCount > 0 { playerLayer.player = player playerLayer.frame = uiView.bounds } } } updateCount was added to force updateUIView called when the parent View increases the updateCount. But it seems not helping much. My question: Is there any known issue about replacing the current item in AVPlayer in SwiftUI app? Here is my code of replacing the current item: let asset = AVURLAsset(url: url) asset.resourceLoader.setDelegate(urlDelegate, queue: urlDelegate.resourceLoaderQueue) let assetKeys = ["playable", "hasProtectedContent"] let playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: assetKeys) player.replaceCurrentItem(with: playerItem) Note that I have a custom delegate to handle the resource loader for the URLAsset. This delegate is the same for all videos. They always plays well when selected first time (i.e. without replacing another video). One more data point: I have an ObjC version of the same design, and it worked without problems.
2
0
1.8k
May ’23
Picture in Picture stops audio when phone locked
AVPlayerViewController has the functionality to keep playing the audio when the app is backgrounded or the device is locked. Obviously picture in picture improves this when the app is backgrounded but we lose the functionality when the device is locked as it stops the audio. The user can hit play on the lock-screen to continue playing but doesn't seem to be ideal. Is there any way around this or is the expected behaviour?
3
0
3.3k
May ’23
Playing apple music from AVFoundation for visualization
Hi I am working on a music app where I can do some sound analysis, my end goal is to integrate Apple Music API in my app where users can search songs. When the song is played I want to show a type of soundwave/spectrogram. For sound visualization I have AVFoundation but the Music API returns only song ID which could be played using Apple MediaPlayer framework only. Is there any API for doing sound analysis or can I play the Apple music songs using AVFoundation.
4
3
2.4k
Apr ’23
ios 16 lockscreen playbutton is disabled but working fine with ios15 (iphone11)
Hello, I have used AVPlayer and AVPlayerViewController to play a video from url. I can control lockscreen play/pause button through avaudiosession as below-- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&sessionError]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; Its working fine with iphone having ios 15, can control play/pause from lockscreen. But in ios 16 iphone , the play/pause button is disabled. Can anyone please help me why its not working with ios 16.
0
0
717
Apr ’23
Picture in Picture does not start by default when you minimise your app in case of AVPlayerLayer
Adopting Picture in Picture in a Custom Player https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_in_a_custom_player I have implemented PIP by following this link when I tap Pip button it works fine but when I am playing any video If I minimise app Picture in Picture does not start .In my case I have used AVPlayerLayer and I have set AVAudiosession category as playback .I am on iOS 14 beta 4
1
0
1.4k
Mar ’23
[tvOS] AVPlayerViewController displays time period label for Live stream
During Live Stream playback on tvOS using AVPlayerViewController we noticed strange time period label: 12:30 PM - 1:00 PM next to the live indicator. It seems that during the start of the playback, the value is set to a 30-minute time period. Questions: What does 12:30 PM - 1:00 PM mean? Can we hide this label or manipulate it using tags in HLS playlist? We do not understand where this value (12:30 PM - 1:00 PM) comes from. Here is an example of our playlist: #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:3 #EXT-X-MEDIA-SEQUENCE:9091 #EXT-X-PROGRAM-DATE-TIME:2023-02-21T12:39:06.640Z As you can see it's not a EXT-X-PROGRAM-DATE-TIME Thanks!
0
0
771
Mar ’23
AVPlayer Fullscreen
Hello everyone, I've a problem with SwiftUI and AVPlayer. When i rotate the device in landscape mode, the player go in fullscreen mode, but when I rotate in portrait it dosn't exit. The struct for AVPlayer: import SwiftUI import AVKit struct AVPlayerControllerRepresentable: UIViewControllerRepresentable { @Binding var showFullScreen: Bool @Binding var player: AVPlayer func makeUIViewController(context: UIViewControllerRepresentableContext<AVPlayerControllerRepresentable>) -> AVPlayerViewController { print("makeUIViewController->",showFullScreen) let controller = AVPlayerViewController() controller.player = player controller.showsPlaybackControls = false; chooseScreenType(controller) return controller } func updateUIViewController(_ uiViewController: AVPlayerViewController , context: UIViewControllerRepresentableContext<AVPlayerControllerRepresentable>) { print("updateUIViewController->",showFullScreen) chooseScreenType(uiViewController) } private func chooseScreenType(_ controller: AVPlayerViewController) { print("chooseScreenType", self.showFullScreen) self.showFullScreen ? controller.enterFullScreen(animated: true) : controller.exitFullScreen(animated: true) } } extension AVPlayerViewController { func enterFullScreen(animated: Bool) { print("Enter full screen") perform(NSSelectorFromString("enterFullScreenAnimated:completionHandler:"), with: animated, with: nil) } func exitFullScreen(animated: Bool) { print("Exit full screen") perform(NSSelectorFromString("exitFullScreenAnimated:completionHandler:"), with: animated, with: nil) } } And this is my View: VStack{ AVPlayerControllerRepresentable(showFullScreen: $fullScreen, player: $player) .ignoresSafeArea() .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in DispatchQueue.main.async { print("change rotation->",UIDevice.current.orientation.rawValue) if UIDevice.current.orientation.isLandscape { print("landscape") self.fullScreen = true } else { print("portrait") self.fullScreen = false } } } .frame(width: 290, height: 220) .overlay { BoxTv() } .opacity(1.0) .padding([.bottom, .top], 40) }.onAppear(){ self.player.play(); } Can anyone help me? When rotate device in portrait mode, the function 'exitFullScreen' isn't called
5
0
5.5k
Mar ’23
FairPlay on iOS 16.1 and onward: AVAssetResourceLoaderDelegate not called with offline DRMs anymore
Hello, We are experiencing a new regression with iOS 16.1/16.2 beta when trying to play a video with offline FairPlay DRMs. Everything was working fine with 16.0.3 and below. The delegate public func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool is never called when you start playing an offline video. It prevents the player to get the DRM and we end up with a timeout CoreMediaError -19512. We tried to preload the existing keys asset.resourceLoader.preloadsEligibleContentKeys = true to no avail. We also looked at the solutions provided in this thread iOS 16 FairPlay Changes which was very similar to our issue but nothing worked for us (we are already using keyRequest.processContentKeyResponse(response)). The DRMs are valid and can be loaded if we move the key to an older iOS device (iOS 16 and below). However, we can see in the logs the following error happening before the CoreMediaError -19512. <<< FigPKDKeyManager >>>> PKDKeyManagerSetKeyRequestError: keyManager: 0x606ce 210 KeyID: F017D7B0-390-45ED-803-01A748DFB7A1 errOr: Error Domain-CoreMediaErrorDomain Code=-19160 " (null)" err: 0 The player just seem not to trigger any delegate starting 16.1+. Is anybody else experiencing the same issue? How can we find out why the delegate aren't triggered? Bests
2
1
2.4k
Mar ’23
AVAsset tracks method does not return all tracks from GoPro mp4 file.
I'm trying to read all the tracks from a GoPro Hero9 camera mp4 file. The AVAsset tracks method says there are only 3 tracks, while ffmpeg says there are 5. I'm particularly interested in the "gpmd" track, which contains GPS data, which AVAsset seemingly does not recognize. Any suggestions? Mac and ffmpeg output below. macOS code XLog(@"AVAsset creation date = %@", asset.creationDate.value); XLog(@"AVAsset tracks.count = %ld", asset.tracks.count); NSArray *trackA = asset.tracks; index = 0; for (AVAssetTrack *track in trackA) { XLog(@"%ld. trackID = %d", index, track.trackID); XLog(@"%ld. mediaType = %@", index, track.mediaType); XLog(@"%ld. data size = %@", index, NSStringFromSize(track.naturalSize)); XLog(@"___________________________"); index++; } } produces 🔷AVAsset creation date = 2022-11-13 13:33:57 +0000 🔷AVAsset tracks.count = 3 🔷0. trackID = 1 🔷0. mediaType = vide 🔷0. data size = {3840, 2160} 🔷___________________________ 🔷1. trackID = 2 🔷1. mediaType = soun 🔷1. data size = {0, 0} 🔷___________________________ 🔷2. trackID = 3 🔷2. mediaType = tmcd 🔷2. data size = {0, 0} ffmpeg -i GX010045.MP4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GX010045.MP4': Metadata: major_brand : mp41 minor_version : 538120216 compatible_brands: mp41 creation_time : 2022-11-13T13:33:57.000000Z location : +38.0357-122.5819/ location-eng : +38.0357-122.5819/ firmware : HD9.01.01.72.00 Duration: 00:08:52.54, start: 0.000000, bitrate: 60206 kb/s Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59941 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro H.265 vendor_id : [0][0][0][0] encoder : GoPro H.265 encoder timecode : 13:33:09:07 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro AAC vendor_id : [0][0][0][0] timecode : 13:33:09:07 Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro TCD timecode : 13:33:09:07 Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 48 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro MET Stream #0:4[0x5](eng): Data: none (fdsc / 0x63736466), 13 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro SOS At least one output file must be specified
1
0
935
Mar ’23
RAW photos display as if overexposed in iOS Photos and MacOS Preview
When capturing RAW (not ProRAW) photos using AVCapturePhotoOutput, the resulting images are subject to a strange overexposed effect when viewed in Apple software. I have been able to recreate this in multiple iOS apps which allow RAW capture. Some users report previously normal images transforming over the span of a few minutes. I have actually watched this happen in real-time: if you observe the camera roll after taking a few RAW photos, the highlights in some will randomly **** (edit: this just says b l o w, nice job profanity filter) out of proportion after whatever is causing this issue kicks in. The issue can also be triggered by zooming in to one of these images from the stock Photos app. Once the overexposure happens on a given image, there doesn't appear to be a way to get it to display normally again. However, if you AirDrop an image to a different device and then back, you can see it display normally at first and then break once more. Interestingly, the photo displays completely fine when viewed in Affinity photo or random photo viewers on Ubuntu. Sometimes the issue is not that bad, but it is often egregious, resulting in completely white areas of a previously balanced photo (see https://discussions.apple.com/thread/254424489). This definitely seems like a bug, but is there any way to prevent it? Could there be an issue with color profiles? This is not the same issue in which users think RAW photos are broken because they are viewing the associated JPG – this happens even with photos that have no embedded JPG or HEIC preview. Very similar (supposedly fixed) issue on MacOS: https://www.macworld.com/article/1444389/overexposed-raw-image-export-macos-monterey-photos-fixed.html Numerous similar complaints: https://discussions.apple.com/thread/254424489 https://discussions.apple.com/thread/253179308 https://discussions.apple.com/thread/253773180 https://discussions.apple.com/thread/253954972 https://discussions.apple.com/thread/252354516
Replies
3
Boosts
3
Views
3.9k
Activity
Jun ’23
import AVKit - no such module on TVOS, possible for ios/multiplatform
When starting a new TVOS project and try to import AVKit it says no such module available. I added them on Frameworks, Libraries and Content - still nothing. Double checked if they are in BuildPhases - Link Binary with LibrariesBuild Phases Cleaned build folder and Derived Data. Nothing Worked. According to Apple's documentation it is supposed to be available for TVOS, but i simply cannot get it to be available. When I start a new multiplatform or iOS project it is possible to import it, just not for TVOS, don't know what to do.Didn't have to add any framework manually, simply worked. No issues when starting a new ios project Project settings iOS. What's going on here?
Replies
3
Boosts
0
Views
2.1k
Activity
Jun ’23
pip not working in iOS 14
I implemented a custom player and used AVPictureInPictureController. pip button is coming and also calling startPictureInPicture() in action. controller.isPictureInPicturePossible is returning true. AVPictureInPictureController delegates are not receiving the call. Any help? func pictureInPictureControllerWillStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {     print("PIP will start") } Have enabled Picture in picture in background mode capability set AVAudioSession category to playback in appdelegate set AVAudioSession.sharedInstance().setActive(true) as true
Replies
1
Boosts
0
Views
1.6k
Activity
Jun ’23
Can we use picture in picture for non-video application?
Can we use picture in picture for non-video application?
Replies
0
Boosts
1
Views
466
Activity
Jun ’23
Can I use AVPlayerViewController with AVPlayerLooper?
I want to use AVPlayerViewController to display the video but it should be in auto-play mode. Previously I was using AVPlayer for that and listening to the .AVPlayerItemDidPlayToEndTime notification but I wonder if there is a better way? eg. using AVPlayerLooper for instance so I don't have to use that .AVPlayerItemDidPlayToEndTime anymore I wrote something like this but it is not working - I have a black screen with video controls - probably because AVPlayerViewController does not have any playable content... struct VideoPlayerQueuedView: UIViewControllerRepresentable { let videoUrl: URL func makeUIViewController(context: Context) -> AVPlayerViewController { let queuePlayer = AVQueuePlayer() let playerViewController = AVPlayerViewController() // Create an AVPlayerItem from the videoUrl let playerItem = AVPlayerItem(url: videoUrl) // Create an AVPlayerLooper with the queuePlayer and the playerItem as the template item let playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: playerItem) // Set the player property of AVPlayerViewController playerViewController.player = queuePlayer return playerViewController } func updateUIViewController(_ uiViewController: AVPlayerViewController, context: Context) { // Update the video player if needed } }
Replies
0
Boosts
0
Views
994
Activity
Jun ’23
Why AVPlayer returns video duration (seconds) as Double?
I need to get video duration in seconds. If I use code below guard let playerItem = self.player?.currentItem else { return 0 } print("playerItem.duration", playerItem.duration, playerItem.duration.seconds, playerItem.duration.toString) it returns me a double value 37.568 CMTime(value: 37568, timescale: 1000, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0) 37.568 00:00:37 I wonder why it's a 37.568 instead of 37.000? if video is 00:00:37? Does it means, it is a 37,5s long?
Replies
2
Boosts
0
Views
1.3k
Activity
May ’23
AVPlayer video track freeze after 1 second while audio continues
Hi, In my SwiftUI app, I'm using AVPlayer and a UIViewRepresentable view to play back a video from a network server. There are many videos on the server, so I have a LazyHStack for the video thumbnails. Only one video is shown on screen at a time. When the user scrolls between videos, I will create a new AVPlayerItem and replace the current player item in the AVPlayer. The problem is: the first video plays back without any problems. But when the user scrolls over to the next video, the new video would play for 1 second and then freezes while the audio track continues. The video track would resume after a few seconds. One note is that if I drag the video view a bit without fully scrolling to another video, the video track will resume after I released the drag. So it seems maybe somehow the AVPlayerLayer was not rendering? Related code pieces: struct PlayerView: UIViewRepresentable { let player: Player let width: CGFloat let height: CGFloat @Binding var updateCount: Int func makeUIView(context: Context) -> UIView { print("\(#function)") let playerLayer = AVPlayerLayer(player: player) let view = UIView() view.frame = CGRectMake(0, 0, width, height) playerLayer.frame = view.bounds view.layer.addSublayer(playerLayer) return view } func updateUIView(_ uiView: UIView, context: Context) { print("\(#function)") guard let playerLayer = uiView.layer.sublayers?.first as? AVPlayerLayer else { return } uiView.frame = CGRectMake(0, 0, width, height) if updateCount > 0 { playerLayer.player = player playerLayer.frame = uiView.bounds } } } updateCount was added to force updateUIView called when the parent View increases the updateCount. But it seems not helping much. My question: Is there any known issue about replacing the current item in AVPlayer in SwiftUI app? Here is my code of replacing the current item: let asset = AVURLAsset(url: url) asset.resourceLoader.setDelegate(urlDelegate, queue: urlDelegate.resourceLoaderQueue) let assetKeys = ["playable", "hasProtectedContent"] let playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: assetKeys) player.replaceCurrentItem(with: playerItem) Note that I have a custom delegate to handle the resource loader for the URLAsset. This delegate is the same for all videos. They always plays well when selected first time (i.e. without replacing another video). One more data point: I have an ObjC version of the same design, and it worked without problems.
Replies
2
Boosts
0
Views
1.8k
Activity
May ’23
Picture in Picture stops audio when phone locked
AVPlayerViewController has the functionality to keep playing the audio when the app is backgrounded or the device is locked. Obviously picture in picture improves this when the app is backgrounded but we lose the functionality when the device is locked as it stops the audio. The user can hit play on the lock-screen to continue playing but doesn't seem to be ideal. Is there any way around this or is the expected behaviour?
Replies
3
Boosts
0
Views
3.3k
Activity
May ’23
AVPlayer seek backwards crash in iOS 16
[AVPlayerItem _seekToTime:toleranceBefore:toleranceAfter:seekID:completionHandler:] Seeking is not possible to time {INVALID}"
Replies
1
Boosts
0
Views
1.2k
Activity
May ’23
AVPlayer not working because Hit maximum timestamp count, will start dropping events
Hi I've made an AVplayer() but when I build it for some reason I press play and then the video player crashes and the debugger says "Hit maximum timestamp count, will start dropping events" do you have any fix for this?
Replies
2
Boosts
0
Views
2.4k
Activity
May ’23
SwiftUI VideoPlayer (Video Controls) in iOS14
Is there a way to disable the default video controls (play/pause/scrubber/etc) on the new SwiftUI VideoPlayer in iOS14, so I could create a custom one?
Replies
6
Boosts
1
Views
12k
Activity
May ’23
Playing apple music from AVFoundation for visualization
Hi I am working on a music app where I can do some sound analysis, my end goal is to integrate Apple Music API in my app where users can search songs. When the song is played I want to show a type of soundwave/spectrogram. For sound visualization I have AVFoundation but the Music API returns only song ID which could be played using Apple MediaPlayer framework only. Is there any API for doing sound analysis or can I play the Apple music songs using AVFoundation.
Replies
4
Boosts
3
Views
2.4k
Activity
Apr ’23
ios 16 lockscreen playbutton is disabled but working fine with ios15 (iphone11)
Hello, I have used AVPlayer and AVPlayerViewController to play a video from url. I can control lockscreen play/pause button through avaudiosession as below-- [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&sessionError]; [[AVAudioSession sharedInstance] setActive:YES error:nil]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; Its working fine with iphone having ios 15, can control play/pause from lockscreen. But in ios 16 iphone , the play/pause button is disabled. Can anyone please help me why its not working with ios 16.
Replies
0
Boosts
0
Views
717
Activity
Apr ’23
subtitle of safari did not disappear.
when we play the streaming with subtitle, it is not disappear until next subtitle data comes. we check data of subtitle and there are end-time data. but end-time data change to infinity on track info of safari browser. is there any solution?
Replies
0
Boosts
0
Views
579
Activity
Apr ’23
Picture in Picture does not start by default when you minimise your app in case of AVPlayerLayer
Adopting Picture in Picture in a Custom Player https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_in_a_custom_player I have implemented PIP by following this link when I tap Pip button it works fine but when I am playing any video If I minimise app Picture in Picture does not start .In my case I have used AVPlayerLayer and I have set AVAudiosession category as playback .I am on iOS 14 beta 4
Replies
1
Boosts
0
Views
1.4k
Activity
Mar ’23
[tvOS] AVPlayerViewController displays time period label for Live stream
During Live Stream playback on tvOS using AVPlayerViewController we noticed strange time period label: 12:30 PM - 1:00 PM next to the live indicator. It seems that during the start of the playback, the value is set to a 30-minute time period. Questions: What does 12:30 PM - 1:00 PM mean? Can we hide this label or manipulate it using tags in HLS playlist? We do not understand where this value (12:30 PM - 1:00 PM) comes from. Here is an example of our playlist: #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:3 #EXT-X-MEDIA-SEQUENCE:9091 #EXT-X-PROGRAM-DATE-TIME:2023-02-21T12:39:06.640Z As you can see it's not a EXT-X-PROGRAM-DATE-TIME Thanks!
Replies
0
Boosts
0
Views
771
Activity
Mar ’23
AVPlayer Fullscreen
Hello everyone, I've a problem with SwiftUI and AVPlayer. When i rotate the device in landscape mode, the player go in fullscreen mode, but when I rotate in portrait it dosn't exit. The struct for AVPlayer: import SwiftUI import AVKit struct AVPlayerControllerRepresentable: UIViewControllerRepresentable { @Binding var showFullScreen: Bool @Binding var player: AVPlayer func makeUIViewController(context: UIViewControllerRepresentableContext<AVPlayerControllerRepresentable>) -> AVPlayerViewController { print("makeUIViewController->",showFullScreen) let controller = AVPlayerViewController() controller.player = player controller.showsPlaybackControls = false; chooseScreenType(controller) return controller } func updateUIViewController(_ uiViewController: AVPlayerViewController , context: UIViewControllerRepresentableContext<AVPlayerControllerRepresentable>) { print("updateUIViewController->",showFullScreen) chooseScreenType(uiViewController) } private func chooseScreenType(_ controller: AVPlayerViewController) { print("chooseScreenType", self.showFullScreen) self.showFullScreen ? controller.enterFullScreen(animated: true) : controller.exitFullScreen(animated: true) } } extension AVPlayerViewController { func enterFullScreen(animated: Bool) { print("Enter full screen") perform(NSSelectorFromString("enterFullScreenAnimated:completionHandler:"), with: animated, with: nil) } func exitFullScreen(animated: Bool) { print("Exit full screen") perform(NSSelectorFromString("exitFullScreenAnimated:completionHandler:"), with: animated, with: nil) } } And this is my View: VStack{ AVPlayerControllerRepresentable(showFullScreen: $fullScreen, player: $player) .ignoresSafeArea() .onReceive(NotificationCenter.default.publisher(for: UIDevice.orientationDidChangeNotification)) { _ in DispatchQueue.main.async { print("change rotation->",UIDevice.current.orientation.rawValue) if UIDevice.current.orientation.isLandscape { print("landscape") self.fullScreen = true } else { print("portrait") self.fullScreen = false } } } .frame(width: 290, height: 220) .overlay { BoxTv() } .opacity(1.0) .padding([.bottom, .top], 40) }.onAppear(){ self.player.play(); } Can anyone help me? When rotate device in portrait mode, the function 'exitFullScreen' isn't called
Replies
5
Boosts
0
Views
5.5k
Activity
Mar ’23
FairPlay on iOS 16.1 and onward: AVAssetResourceLoaderDelegate not called with offline DRMs anymore
Hello, We are experiencing a new regression with iOS 16.1/16.2 beta when trying to play a video with offline FairPlay DRMs. Everything was working fine with 16.0.3 and below. The delegate public func resourceLoader(_ resourceLoader: AVAssetResourceLoader, shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest) -> Bool is never called when you start playing an offline video. It prevents the player to get the DRM and we end up with a timeout CoreMediaError -19512. We tried to preload the existing keys asset.resourceLoader.preloadsEligibleContentKeys = true to no avail. We also looked at the solutions provided in this thread iOS 16 FairPlay Changes which was very similar to our issue but nothing worked for us (we are already using keyRequest.processContentKeyResponse(response)). The DRMs are valid and can be loaded if we move the key to an older iOS device (iOS 16 and below). However, we can see in the logs the following error happening before the CoreMediaError -19512. <<< FigPKDKeyManager >>>> PKDKeyManagerSetKeyRequestError: keyManager: 0x606ce 210 KeyID: F017D7B0-390-45ED-803-01A748DFB7A1 errOr: Error Domain-CoreMediaErrorDomain Code=-19160 " (null)" err: 0 The player just seem not to trigger any delegate starting 16.1+. Is anybody else experiencing the same issue? How can we find out why the delegate aren't triggered? Bests
Replies
2
Boosts
1
Views
2.4k
Activity
Mar ’23
AVAsset tracks method does not return all tracks from GoPro mp4 file.
I'm trying to read all the tracks from a GoPro Hero9 camera mp4 file. The AVAsset tracks method says there are only 3 tracks, while ffmpeg says there are 5. I'm particularly interested in the "gpmd" track, which contains GPS data, which AVAsset seemingly does not recognize. Any suggestions? Mac and ffmpeg output below. macOS code XLog(@"AVAsset creation date = %@", asset.creationDate.value); XLog(@"AVAsset tracks.count = %ld", asset.tracks.count); NSArray *trackA = asset.tracks; index = 0; for (AVAssetTrack *track in trackA) { XLog(@"%ld. trackID = %d", index, track.trackID); XLog(@"%ld. mediaType = %@", index, track.mediaType); XLog(@"%ld. data size = %@", index, NSStringFromSize(track.naturalSize)); XLog(@"___________________________"); index++; } } produces 🔷AVAsset creation date = 2022-11-13 13:33:57 +0000 🔷AVAsset tracks.count = 3 🔷0. trackID = 1 🔷0. mediaType = vide 🔷0. data size = {3840, 2160} 🔷___________________________ 🔷1. trackID = 2 🔷1. mediaType = soun 🔷1. data size = {0, 0} 🔷___________________________ 🔷2. trackID = 3 🔷2. mediaType = tmcd 🔷2. data size = {0, 0} ffmpeg -i GX010045.MP4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'GX010045.MP4': Metadata: major_brand : mp41 minor_version : 538120216 compatible_brands: mp41 creation_time : 2022-11-13T13:33:57.000000Z location : +38.0357-122.5819/ location-eng : +38.0357-122.5819/ firmware : HD9.01.01.72.00 Duration: 00:08:52.54, start: 0.000000, bitrate: 60206 kb/s Stream #0:0[0x1](eng): Video: hevc (Main) (hvc1 / 0x31637668), yuvj420p(pc, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 59941 kb/s, 59.94 fps, 59.94 tbr, 60k tbn (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro H.265 vendor_id : [0][0][0][0] encoder : GoPro H.265 encoder timecode : 13:33:09:07 Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro AAC vendor_id : [0][0][0][0] timecode : 13:33:09:07 Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74) (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro TCD timecode : 13:33:09:07 Stream #0:3[0x4](eng): Data: bin_data (gpmd / 0x646D7067), 48 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro MET Stream #0:4[0x5](eng): Data: none (fdsc / 0x63736466), 13 kb/s (default) Metadata: creation_time : 2022-11-13T13:33:57.000000Z handler_name : GoPro SOS At least one output file must be specified
Replies
1
Boosts
0
Views
935
Activity
Mar ’23
My app canceled by Guideline 2.5.4 - Performance - Software Requirements, although I have done well
In my app i use AVPlayer to be able to enter Picture in Picture mode in my video and it works great, but for some reason my app got canceled anyway because of this reason, i want to know what i did wrong
Replies
1
Boosts
1
Views
1k
Activity
Mar ’23