avplayeritem

AVPlayer status AVPlayerStatusFailed not working Properly

痴心易碎 提交于 2021-01-28 17:35:25
问题 I am implementing AVPlayer (not AVAudioPlayer) and trying to play audio from URL. It is working fine. But as we know that sometimes we can have invalid URL (URL that does not have Audio byte). When I play audio from any URL AVPlayer status shows always AVPlayerStatusReadyToPlay which is wrong. For example : In URL part if give invalid URL like : http://soundx.mp3slash.net/indian/jhankar_beats/1%28mp3pk.com%29.mp3 (it does not works even in your browser) and even if you give https:/

Mojave/macOS 10.14.0: [AVPlayerItem duration] is always indefinite

我的梦境 提交于 2021-01-28 02:26:06
问题 I'm trying to read the duration of a locally stored audio file using the following code: #import <Foundation/Foundation.h> #import <CoreMedia/CoreMedia.h> #import <AVFoundation/AVFoundation.h> AVPlayer *player = [AVPlayer playerWithURL: urlForLocalAudioFile]; // busy wait - I know, not elegant, please ignore int timeout = 0; while (([player status] == AVPlayerStatusUnknown || [[player currentItem] status] == AVPlayerItemStatusUnknown) && timeout < 100) { [NSThread sleepForTimeInterval: 0.1];

Too many AVPlayers causes Terminated due to memory issue

穿精又带淫゛_ 提交于 2021-01-01 10:00:05
问题 I have a vc that has an AVPlayer inside of it. From that vc I can push on a different vc with another player inside of it and I can keep pushing on more vcs with a player inside them also. After about the 14th vc getting pushed on the app crashes with Terminated due to memory issue . When I look at the memory graph (9th icon in left pane) it's at about 70mb so there isn't an obscene jump in memory. All of my video files are saved to and retrieved from disk and whenever I pop a vc I have a

Too many AVPlayers causes Terminated due to memory issue

孤街醉人 提交于 2021-01-01 09:58:28
问题 I have a vc that has an AVPlayer inside of it. From that vc I can push on a different vc with another player inside of it and I can keep pushing on more vcs with a player inside them also. After about the 14th vc getting pushed on the app crashes with Terminated due to memory issue . When I look at the memory graph (9th icon in left pane) it's at about 70mb so there isn't an obscene jump in memory. All of my video files are saved to and retrieved from disk and whenever I pop a vc I have a

Does setting the AVPlayerItem after creating the AVPlayer increase efficiency in iOS 13?

删除回忆录丶 提交于 2020-06-29 04:45:34
问题 In a WWDC 2016 video, Apple says create the AVPlayer without an AVPlayerItem, create the AVPlayerLayer, and then assign the AVPlayerItem to the AVPlayer. I got the above code from @matt's Programming iOS 10 book. In it he says: Apparently there is some sort of efficiency if you do things in this order. The reason, it turns out, is that when an AVPlayerItem is assigned to an AVPlayer that doesn't have and associated AVPlayerLayer, the AVPlayer assumes that only the audio track of the AVAssest

How to play AVPlayerItems immediately

為{幸葍}努か 提交于 2020-06-25 05:19:08
问题 I'm using AVPlayer which I connect to an remote URL via an AVPlayerItem . The problem is that I want to play the sound from the URL immediately and don't let the user wait for the AVPlayer to buffer. The thing is that if the remote URL's asset media is very short then it doesn't buffer for long at all but if the media is a bit longer it takes a while. Is there a way to skip the buffering process or at least shorten it substantially? 回答1: Swift 5 You just need to use the

Add custom controls to AVPlayer in swift

早过忘川 提交于 2020-01-18 22:41:20
问题 I am trying to create a table view such that I am able to play videos . I am able to do this using AVPlayer and layer. I want to add a custom play and pause button with a slider to the bottom of a video view. AVPlayerController comes built in with these controls. How can I implement these in AVPlayer. I have been looking for examples. But I haven't found any. Are there any GitHub examples or code samples that I can follow? Any help will be really appreciated. 回答1: here I add the points , you

Add custom controls to AVPlayer in swift

偶尔善良 提交于 2020-01-18 22:39:51
问题 I am trying to create a table view such that I am able to play videos . I am able to do this using AVPlayer and layer. I want to add a custom play and pause button with a slider to the bottom of a video view. AVPlayerController comes built in with these controls. How can I implement these in AVPlayer. I have been looking for examples. But I haven't found any. Are there any GitHub examples or code samples that I can follow? Any help will be really appreciated. 回答1: here I add the points , you

AVPlayer fails with AVPlayerItemStatusFailed (OSStatus error -12983)

ぃ、小莉子 提交于 2020-01-01 08:43:13
问题 Sometimes AVPlayer fails with AVPlayerItemStatusFailed and after that failure occurred, AVPlayer continues to failed with AVPlayerItemStatusFailed . I tried to clear the AVPlayer instance and create new one, but I cannot achieve AVPlayerItemStatusFailed failure to solve. Also removingFromSuperview UIView with AVPlayer instance and initializing new item with AVPlayer does not solve the problem. So I figured that out AVPlayer couldn't been cleared completely. Is there anybody suggest anything

AVPlayer fails with AVPlayerItemStatusFailed (OSStatus error -12983)

随声附和 提交于 2020-01-01 08:40:06
问题 Sometimes AVPlayer fails with AVPlayerItemStatusFailed and after that failure occurred, AVPlayer continues to failed with AVPlayerItemStatusFailed . I tried to clear the AVPlayer instance and create new one, but I cannot achieve AVPlayerItemStatusFailed failure to solve. Also removingFromSuperview UIView with AVPlayer instance and initializing new item with AVPlayer does not solve the problem. So I figured that out AVPlayer couldn't been cleared completely. Is there anybody suggest anything