Tag: avplayer

AVPlayer不正确地播放video合成结果

我需要一个简单的东西: 在旋转和应用CIFilter同时播放video。 首先,我创build玩家项目: AVPlayerItem *item = [AVPlayerItem playerItemWithURL:videoURL]; // DEBUG LOGGING AVAssetTrack *track = [[item.asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; NSLog(@"Natural size is: %@", NSStringFromCGSize(track.naturalSize)); NSLog(@"Preffered track transform is: %@", NSStringFromCGAffineTransform(track.preferredTransform)); NSLog(@"Preffered asset transform is: %@", NSStringFromCGAffineTransform(item.asset.preferredTransform)); 然后我需要应用video作品。 最初,我正在考虑用2条指令创build一个AVVideoComposition ,一个是AVVideoCompositionLayerInstruction ,另一个是CIFilter应用程序。 然而,我得到一个exception抛出说: “期望video组成只包含AVCoreImageFilterVideoCompositionInstruction”这意味着苹果不允许结合这两个指令。 所以,我把这两个过滤结合起来,这里是代码: AVAsset *asset = playerItem.asset; CGAffineTransform rotation = [self transformForItem:playerItem]; AVVideoComposition *composition = [AVVideoComposition videoCompositionWithAsset:asset […]

AVPlayer – 快速向后/向前stream

这是我在viewDidLoad中的代码: AVPlayerItem* playerItem = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://groove.wavestreamer.com:7321/listen.pls?sid=1"]]; [playerItem addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil]; music = [[AVPlayer playerWithPlayerItem:playerItem] retain]; [music play]; 我的问题: 我怎样才能创build一个button,快速向前/快速倒退stream5秒,当它被按下? 谢谢您的回答… :) 编辑:如何添加到我目前的时间… CMTime currentTime = music.currentTime; … 5秒钟?

为什么Swift的AVPlayer会在一次播放中加载playerItem两次?

我正在使用AVFoundation的AVPlayer来stream式传输外部mp3文件。 我在后端有一个计数器来计算文件加载的次数。 这个服务的唯一客户端只有我,每当我触发播放AVPlayer,计数器增加两个,这意味着AVPlayer请求两次。 有没有这个原因,或者我怎样才能防止这种情况发生? 这是我的代码: @IBAction func listen(sender: UIButton) { let urlstring = "http://api.server.com/endpoint-to-mp3" let url = NSURL(string: urlstring) let playerItem = AVPlayerItem(URL: url!) let player = AVPlayer(playerItem: playerItem) let playerLayer = AVPlayerLayer(player: player) playerLayer.frame = CGRectMake(0, 0, 300, 50) self.view.layer.addSublayer(playerLayer) player.volume = 1.0 player.play() }

IOS AVPlayer获取fps

我试图找出如何通过AVPlayer检索video帧率。 AVPlayerItem有一个速率variables,但它只返回一个介于0和2之间的值(通常在播放时为1)。 任何人有一个想法如何获得video帧率? 干杯

addPeriodicTimeObserverForInterval调用额外的时间

我有一个AVPlayer与4秒的video( NSTimeInterval duration = CMTimeGetSeconds(self.playerItem.asset.duration) = 4)。 我想更新UI的变化: self.periodicTimeObserver = [self.player addPeriodicTimeObserverForInterval:CMTimeMake(1, 1) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) { [weakSelf currentTimeDidChange:CMTimeGetSeconds(time)]; }]; 但由于某些原因,我得到了额外的UI调用: – (void)currentTimeDidChange:(NSTimeInterval)currentTime { NSLog(@"timePassed %f, total: %f", currentTime, self.duration); } 日志: 2015-07-23 13:47:07.412 timePassed 0.000000, total: 4.000000 2015-07-23 13:47:07.448 timePassed 0.002814, total: 4.000000 2015-07-23 13:47:07.450 timePassed 0.005481, total: 4.000000 2015-07-23 13:47:08.447 timePassed 1.001473, total: […]

iOS AVPlayer在播放图标上显示交叉线的屏幕

Screen Shot of AVPlayer error 下面是代码片段,url是videourl。 这个错误随机发生。 我无法追查是什么问题。 video也存储在云端和video监听器上播放AVPlayer。 下面的代码中缺less任何东西。 + (void)presentVideoForURL:(NSURL *)URL parentViewController:(UIViewController *)parentViewController { AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *setCategoryError; if (![audioSession setCategory:AVAudioSessionCategoryPlayback error:&setCategoryError]) { Error(@"setCategoryError %@", setCategoryError.localizedDescription); } NSError *activationError; if (![audioSession setActive:YES error:&activationError]) { Error(@"activationError: %@", activationError.localizedDescription); } AVPlayer *player = [[AVPlayer alloc] initWithURL:URL]; AVPlayerViewController *playerController = [[AVPlayerViewController alloc] init]; […]

在AVQueuePlayer中检测当前项目并知道它何时更改?

我目前有一个AVQueuePlayer按顺序播放几个.aif文件。 当它通过每个audio时,我想要执行与特定声音相关的操作(例如,更改imageview的uiimage)。 我的问题是正确设置NSNotification。 我已经设置它通知我,当队列完成最后一个对象,但我无法收到每个当前项目的通知。 这是我有什么: //Setting Up My Queue List yellowVoice = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/YellowVoice.aif", [[NSBundle mainBundle] resourcePath]]]]; orangeVoice = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/OrangeVoice.aif", [[NSBundle mainBundle] resourcePath]]]]; redVoice = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/RedVoice.aif", [[NSBundle mainBundle] resourcePath]]]]; pinkVoice = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/PinkVoice.aif", [[NSBundle mainBundle] resourcePath]]]]; NSArray *soundEmotions = [NSArray arrayWithObjects:yellowVoice, […]

设备locking时从iPod库中播放AVAudio

只是一个简单的问题。 我已经build立了我的程序能够在后台播放AVAudioPlayer和AVPlayer ,这是工作正常。 我可以播放一首歌曲,locking我的屏幕,声音将继续播放。 我遇到的麻烦是调用[AVPlayer play]而我的屏幕已被locking。 这最终导致没有音乐被播放。

检测AVPlayerViewController是否正在播放video或缓冲并向播放器添加覆盖

我必须检测video是否在播放或缓冲模式。我从URL加载video。 我已经尝试了下面的代码,我可以追踪一次video开始播放,但不是当它在缓冲状态。 另外,我想在我的播放器中添加一个覆盖视图。 我曾尝试在AVPlayer中添加叠加层,但在全屏模式下叠加层消失。 需要一些build议。 提前致谢。 以下是我的代码: let playerAV = AVPlayerViewController() var player = AVPlayer() player = AVPlayer(URL: url) print(url) playerAV.player = player playerAV.view.frame = CGRectMake(0, 0, self.videoView.frame.width, self.videoView.frame.height) self.addChildViewController(playerAV) self.videoView.addSubview(playerAV.view) playerAV.didMoveToParentViewController(self) playerAV.player?.play() NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ChannelDetailViewController.notificationObserver(_:)), name:AVPlayerItemDidPlayToEndTimeNotification , object: player.currentItem) _ = UIDevice.beginGeneratingDeviceOrientationNotifications NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(ChannelDetailViewController.deviceOrientationDidChange(_:)) , name: UIDeviceOrientationDidChangeNotification, object: nil) player.addObserver(self, forKeyPath: "rate", options: […]

AVPlayer问题,而直播stream媒体(iOS)

我有AVPlayer的问题。 1.如何控制音量? 2.如何知道AVPlayer是否因为连接不良而重新加载音乐,我有一些解决办法吗?