avplayer

AVPlayer Not Loading Media In Background

早过忘川 提交于 2019-12-07 23:45:06
问题 When running in the background, my implementation of the AVPlayer is unable to play audio (e.g. podcast) that is downloaded, but is able to play songs that are stored locally. Failure to play in the background is only when the phone is disconnected from my computer. If my phone is direct connected to my computer/debugger, any media that is local or is downloaded plays without a problem. In the foreground, there is also no problem playing either media type. Here is my implementation: AVPlayer

Using AVPlayer for streaming is slow

笑着哭i 提交于 2019-12-07 23:44:50
问题 I use AVPlayer for streaming mp3 file from the internet and it works really slow. Using profiler I found out, that it downloads entire file at first, and then starts playing. Is there any workaround for this? Right now, I'm using this code if let player = player { NotificationCenter.default.removeObserver(self, name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem) let item = AVPlayerItem(url: url) player.replaceCurrentItem(with: item) } else { player = AVPlayer

AVPlayer blank video: playing sound but no video

北城余情 提交于 2019-12-07 22:57:11
问题 This question has the same problem, but the solutions didn't work. The AVPlayer sometimes plays a blank video: there is sound but no video. While blank videos were played, we printed the frame and status of the player. The frame was non-zero and was correctly set. The status was also readyToPlay . The play function is also invoked on the main thread. In other words, the frame for the player layer is valid, and the player is also ready to play. Yet no video appears, even though sound does. The

Accesing Individual Frames using AV Player

眉间皱痕 提交于 2019-12-07 18:52:42
问题 In a recent project, I have to access all frames of my video individually using AV Foundation. Also, if possible to acess them randomly (like an array) I tried to research the question but I didn't get anything useful. Note: Is there any useful documentation to get familiar with the AV Foundation ? 回答1: You can enumerate the frames of your video serially using AVAssetReader , like this: let asset = AVAsset(URL: inputUrl) let reader = try! AVAssetReader(asset: asset) let videoTrack = asset

How do I make AVCaptureSession and AVPlayer respect AVAudioSessionCategoryAmbient?

陌路散爱 提交于 2019-12-07 17:13:45
问题 I'm making an app that records ( AVCaptureSession ) and plays ( AVPlayerLayer ) video. I'd like to be able to do this without pausing background audio from other apps and I'd like the playback to respect the mute switch. In the AppDelegate I have set AVAudioSessionCategoryAmbient , according to the docs this should: The category for an app in which sound playback is nonprimary—that is, your app can be used successfully with the sound turned off. This category is also appropriate for “play

AVPlayer Can't Play

前提是你 提交于 2019-12-07 15:57:29
问题 I want to play a remote mp3 with AVPlayer. I can't make it work and I can't see the reason why it doesn't work. Code: NSString *urlstr=@"..some link to a mp3" NSURL *url=[NSURL URLWithString:urlstr]; self.player = [[[AVPlayer alloc] initWithURL:url] retain]; [player play]; The link is valid. If I load it in a webView it plays right away. Please help. 回答1: I have get a solution. Please try the following code: NSString *urlstr=@"http://www.3rdeyelab.com/mp3/mp3/tailtoddle_lo.mp3" NSURL *url=

AVPlayer Play, Pause and Buffering issue

我怕爱的太早我们不能终老 提交于 2019-12-07 15:57:19
问题 My app plays a streaming video, but when it buffers, the player goes to the pause mode and I have to set it to play mode again manually, I have the following code in my AVPlayer class in order to handle this situation, but it does not work. In the ViewDidLoad method [playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil]; [playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];

How do I loop a video with AVFoundation without unwanted pauses at the end?

巧了我就是萌 提交于 2019-12-07 14:43:55
问题 I am trying to play a video clip that loops indefinitely. I am doing this the way Apple recommends; by setting up a notification that gets triggered by AVPlayerItemDidPlayToEndTimeNotification: @property(nonatomic) AVPlayer *videoPlayer; @property(nonatomic) AVPlayerItem *videoPlayerItem; -(void)loadVideo { NSURL *url = [[NSBundle mainBundle] URLForResource:filename withExtension:extension]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; NSString *tracksKey = @"tracks";

AVPlayerItem addobserver issue in iOS8

匆匆过客 提交于 2019-12-07 13:37:00
问题 Hi I am playing video on my UITableViewCells using AVPlayer, It was working fine on iOS 7, but in iOS8 it crashing with following error. 'An instance 0x7c01b000 of class AVPlayerItem was deallocated while key value observers were still registered with it. Here is my code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ......... ......... if(cell.videoPlayer!= nil && cell.videoPlayer.currentItem != nil) { [cell.videoItem removeObserver

How to play multiple videos smoothly in iOS in UICollectionView?

元气小坏坏 提交于 2019-12-07 10:48:09
问题 I want to play multiple videos in infinite loop in my collection view. Each Video represent a cell. I am using ALAsset. I am playing this using AVPLayer but it's not loading and playing smoothly. Any Suggestions. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; CGRect attachmentFrame =