avqueueplayer

AVFoundation play consecutive video fragments

你说的曾经没有我的故事 提交于 2020-01-03 03:12:40
问题 I am working on an iOS app that involves fetching video fragments that are part of a stream from a web server and playing them consecutively inside the app. After some research, I decided to use an AVQueuePlayer. Every time I fetch an MP4 file from the server and store it in an NSData object, I create an AVPlayerItem and append it to the queue. Also, I listen to the AVPlayerItemDidPlayToEndTimeNotification notification where I advance to next item. The issue I am facing is an annoying small

Play/Pause/Stop multiple audio file which are stored locally

时光毁灭记忆、已成空白 提交于 2019-12-24 12:11:37
问题 I have 20 audio tracks, which are stored locally in my project. I want to play all that files sequentially . For that I have used AVQueuePlayer. Please check below code for reference. Declaration :- @interface ViewController () { AVAudioPlayer *player; NSMutableArray *arrPlayData; AVPlayerItem *item; } @property (nonatomic, retain) AVQueuePlayer *queuePlayer; Button Clicks as below, -(IBAction)click_Play:(id)sender { for (int j = 0; j < arrPlayData.count; j++) { path =[[NSBundle mainBundle]

how to use AVQueuePlayer in AVPlayer

空扰寡人 提交于 2019-12-24 03:39:41
问题 currently i am using following codes to play song playerItem = [AVPlayerItem playerItemWithURL:[song valueForProperty:MPMediaItemPropertyAssetURL]]; [_avPlayer replaceCurrentItemWithPlayerItem:playerItem]; here i am using AVPlayer for playing audio files, but my requirement is need to play group (NSArray) of song continuously(currently player stop after playing one song).I heared about AVQueuePlayer but don't know how to use is it with avplayer if anyone know this please help me 回答1: Look at

AVQueuePlayer: Loop last item in a queue (and eliminate hiccup) or loop last seconds of a video

大城市里の小女人 提交于 2019-12-23 16:25:21
问题 I am using AVQueuePlayer to play videos in sequence (although I have hiccups between plays). Now I'd like to: 1) Loop the last item in that sequence (not the full one). 2) In doing so, I'd also like to eliminate hiccups. Below is my code to play the videos sequence. How could I achieve my 2 goals? [super viewDidLoad]; NSString *secondVideoPath = [[NSBundle mainBundle] pathForResource:@"vid_1" ofType:@"mov"]; NSString *firstVideoPath = [[NSBundle mainBundle] pathForResource:@"vid_2" ofType:@

How to start next a Song or recognized that a song is finished while playing with AVPlayer?

三世轮回 提交于 2019-12-21 22:22:24
问题 How can I start next song immediately with AVPlayer? I have collections of song selected from iPod Library in MPMediaItemCollection . Now how can i use AVPlayer for lists of songs to be played one by one?? 回答1: For answer to your first question, You can use Notification for the same as [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(songFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:[yourAVPlayer currentItem]]; -(void)songFinished:(NSNotification *

Detecting AVPlayer video start stop events

余生长醉 提交于 2019-12-21 20:13:02
问题 Here is nice simple avplayer piece of code playing a small collection of videos in a queue. My question. I actually want to pause between videos on my queue. Is it possible? I did note that rate fires twice; status fires just once as does notification. import UIKit import AVKit import AVFoundation class ViewController: UIViewController { @IBOutlet weak var VideoView: UIView! var player:AVQueuePlayer = AVQueuePlayer() @IBAction func NextSlide(sender: AnyObject) { player.play() } override func

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

AVPlayer “freezes” the app at the start of buffering an audio stream

依然范特西╮ 提交于 2019-12-17 22:04:06
问题 I am using a subclass of AVQueuePlayer and when I add new AVPlayerItem with a streaming URL the app freezes for about a second or two. By freezing I mean that it doesn't respond to touches on the UI. Also, if I have a song playing already and then add another one to the queue, AVQueuePlayer automatically starts preloading the song while it is still streaming the first one. This makes the app not respond to touches on the UI for two seconds just like when adding the first song but the song is

An AVPlayerItem can occupy only one position in a player's queue at a time?

旧城冷巷雨未停 提交于 2019-12-13 08:29:36
问题 I have seen many questions on this and none have had a solution. I am getting: An AVPlayerItem can occupy only one position in a player's queue at a time In the console after quickly taping a view button which should have one of two states: Successfully preloaded video only a videoURL which will then be loaded in another VC. Why is this happening and how can I fix it? This is my code which handels this in the transitioned to VC: if numberMedia == 0 { if selectedPost!.interimMedia[numberMedia]

Receiving RemoteControlEvents to First Tab when interacting in Second Tab in a TabBar Controlled iOS App

孤人 提交于 2019-12-12 14:47:02
问题 I am developing an iOS app with a tab bar controller. In the first tab, I placed an instance of AVQueuePlayer to start playing music from the web. I did all coding to allow play and pause events through remote control events. But I could able to receive remote control events only when I stay in the first tab. When I switch to other tabs, remote control events are not received to the first tab. When I place the following lines in first tab view controller, I can receive remote control events