avplayeritem

Swift AVPlayerItem close when finished

荒凉一梦 提交于 2019-12-24 12:30:08
问题 I'm extremely new to Swift and iOS development, so please forgive my ignorance. I'm trying to have the AVPlayer close automatically when the video is done playing. I've thought to attach the "playerDidFinishPlaying" listener to receive the notification, but once I have it, I can't find the method/event to close the Controller. I'm looking to mimic the action of clicking the "Done" button. Here is a small snippet of code. Hopefully this is enough information. If not, I can provide further info

AVPlayerItem.duration returns as NaN even after player.status == .readyToPlay

霸气de小男生 提交于 2019-12-24 05:54:47
问题 I have an implementation using KVO on player.status much like the suggestion documented here. Here's the relevant bits: var player: AVPlayer? var url = URL(string: "some video url")! override func viewDidLoad() { super.viewDidLoad() initializeVideoPlayer() } func initializeVideoPlayer() { let playerItem = AVPlayerItem(url: url) self.player = AVPlayer(playerItem: playerItem) let playerLayer = AVPlayerLayer(player: player) playerLayer.frame = self.view.layer.bounds videoView.layer.addSublayer

AVPlayerItem.duration returns as NaN even after player.status == .readyToPlay

霸气de小男生 提交于 2019-12-24 05:54:05
问题 I have an implementation using KVO on player.status much like the suggestion documented here. Here's the relevant bits: var player: AVPlayer? var url = URL(string: "some video url")! override func viewDidLoad() { super.viewDidLoad() initializeVideoPlayer() } func initializeVideoPlayer() { let playerItem = AVPlayerItem(url: url) self.player = AVPlayer(playerItem: playerItem) let playerLayer = AVPlayerLayer(player: player) playerLayer.frame = self.view.layer.bounds videoView.layer.addSublayer

Observing values on AVPlayerItem in iOS9

馋奶兔 提交于 2019-12-21 02:47:12
问题 I have an app that uses AVPlayer to play an AVPlayerItem (video) from a remote URL. In iOS 6-8 I have been observing the AVPlayerItem's value for loadedTimeRanges to notify me when the playerItem is ready to be played by the player. This also works when observing the value for the item's duration , I believe. After updating to iOS 9 beta, none of the values on AVPlayerItem I observe ever makes it to the observeValueForKeyPath -method. Just as if I'm not observing them at all. I am still being

How to close previous AVPlayer and AVPlayerItem

喜你入骨 提交于 2019-12-21 02:34:09
问题 I'm making an iOS app in Swift that plays a video in a loop in a small layer in the top right corner of the screen which shows a video of specific coloured item. the user then taps the corresponding coloured item on the screen. when they do, the videoName variable is randomly changed to the next colour and the corresponding video is triggered. I have no problem raising, playing and looping the video with AVPlayer, AVPlayerItem as seen in the attached code. Where I'm stuck is that whenever the

How to find AVPlayer current bitrate

自闭症网瘾萝莉.ら 提交于 2019-12-20 10:57:17
问题 I am trying to fetch bit rate at which the AVPlayer is playing the video stream . I tried with observed bit rate property of AVPlayerItemAccessLogEvent , but it gives very high value.After exploring further on Observed-bit-rate property I understood that this property shows the value of download rate of a segment .I need to know the bit rate at which the player is playing the stream. The graph below shows Observed bit vs Indicated bit rate for the LIVE stream. Kindly give your suggestion on

AVPlayer was deallocated while key value observers were still registered with it

孤者浪人 提交于 2019-12-20 08:47:15
问题 I am creating a simple media player app. My App is crashed when first link is played and I clicked second link in uitableview. - (void)viewDidLoad { [super viewDidLoad]; arrURL = [NSArray arrayWithObjects: @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=148820", @"http://www.kcrw.com/pls/kcrwmusic.pls",@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=175821",@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=148820",@"http://yp.shoutcast.com/sbin/tunein-station.pls?id=70931",nil];

iOS - Detecting if an URL stream is working or not, with AVPlayer

这一生的挚爱 提交于 2019-12-20 04:31:30
问题 This is how in my code, playing from url, looks like: private func play() { let streamUrl = ... let playerItem = AVPlayerItem(url: streamURL) radioPlayer = AVPlayer(playerItem: playerItem) radioPlayer.volume = 1.0 do { try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: AVAudioSessionCategoryOptions.mixWithOthers) try AVAudioSession.sharedInstance().setActive(true) UIApplication.shared.beginReceivingRemoteControlEvents() } catch { print("Error deactivating

Better way to do skip to previous with AVQueuePlayer?

心不动则不痛 提交于 2019-12-18 11:50:42
问题 I am using an AVQueuePlayer in my app. I have a two swipe gestures to skip to next and skip to previous avplayeritems. Right now to do skip to next I am just calling advanceToNextItem on the avqueueplayer which works well. However the skip to previous I am removing all items and adding them back in with the previous video up front, this is really slow when skipping to previous multiple times. How can I make this faster just like calling advanceToNextItem ? My code looks like this: func

Updating AVPlayerItem video composition

倾然丶 夕夏残阳落幕 提交于 2019-12-18 09:09:07
问题 Me and my team are stuck on an issue for a few days now. We have AVPlayer which plays AVPlayerItem with a custom AVVideoComposition . player.currentItem?.videoComposition = getUpdatedVideoComisition() The user can decide if to remove or keep the composition. I'm trying to remove the composition by calling player.currentItem?.videoComposition = nil But in an unexpected way even when assigning nil to the videoComposition property, it's keep on playing with the same composition. How can we