Tag: avplayerviewcontroller

隐藏Quicktime Logo / AVPlayerViewControllerContentView图像

从avplayer中隐藏AVPlayerViewControllerContentView图像,因为它有时出现并且卡住了用户。 请find图像: –

强制方向在iOS 10设备中不起作用

目前,我正在做AVPlayer全屏button按下时强制方向的变化。我尝试了类似的东西 final class NewMoviePlayerViewController: AVPlayerViewController { override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if contentOverlayView?.bounds == UIScreen.main.bounds{ DispatchQueue.main.async { let value = UIInterfaceOrientation.landscapeRight.rawValue UIDevice.current.setValue(value, forKey: "orientation") } print("full screen") }else{ DispatchQueue.main.async { let value = UIInterfaceOrientation.portrait.rawValue UIDevice.current.setValue(value, forKey: "orientation") } print("half screen") } } } 上面的代码在iOS 11中工作正常,但相同的代码不工作在iOS 10和以下版本

iOS中的AVPlayerViewController播放/暂停问题

我正在开发iOS应用程序。 这个应用程序基于新闻媒体。 我正在播放突出显示的新闻的小video。 我正面临AVPlayerViewController的陌生人问题。 当我播放video一切都很好。 当我离线时,缓冲区video播放完毕播放缓冲区video后,video停止,但progress bar(Slider)连续处于播放状态,video停止播放。 要获得更多的通关请看这个GIF图像: 请访问此链接了解连击。 这是我的玩家代码。 class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. self.playVideo() } func playVideo(){ let videoURL = NSURL(string: "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8") let player = AVPlayer(URL: videoURL!) let playerController = AVPlayerViewController() playerController.player = player self.addChildViewController(playerController) self.view.addSubview(playerController.view) […]

我们可以使用语音框架而videoplayback进行?

我正在使用AVPlayerController播放video,同时我想使用语音命令来停止video。 所以我试图使用语音框架相同,但我得到错误com.apple.coreaudio.avfaudio',原因:'所需的条件是false:format.sampleRate == hwFormat.sampleRate' 在使用Speech框架进行logging时,我尝试使用类别进行会话 [AVAudioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&sessionError]; 在recognitionTaskWithRequest中也没有得到任何回应 无论我需要检查降噪algorithm还是其他一些我必须做的工作。 这可能吗? 任何帮助或build议将不胜感激。

检测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: […]

恢复AVPlayerstream播放的最后一个示例

我正尝试使用本地播放器(AVPlayer)在iOS上重现实时stream。 但是,我无法恢复播放。 停止播放并在几秒后恢复播放时,播放将从暂停的那一刻开始,而不是再现实时stream的当前(最后一个)样本。 有没有办法得到最后一个样品,oconfigurationAVPlayer从最后一个样品点击播放button时重现?

如何replaceMPMoviePlayer通知?

在iOS 9 MPMoviePlayer和他的所有组件都被弃用。 我们使用MPMoviePlayerController通知,如MPMoviePlayerLoadStateDidChangeNotification, MPMovieDurationAvailableNotification, MPMoviePlayerPlaybackStateDidChangeNotification, MPMoviePlayerReadyForDisplayDidChangeNotification ,来跟踪video服务质量。 但现在用AVPlayerViewController我无法find正确的替代这些通知。 我现在如何replace这些通知?

Swift AVPlayerViewController添加AirPlay

我试图启用AirPlay与我的AVPlayerViewController 。 在文件中: https://developer.apple.com/reference/avkit/avplayerviewcontroller 它指出 AVPlayerViewController automatically supports AirPlay, but you need to perform some project and audio session configuration before it can be enabled in your application. 在Capabilities选项卡下,我确实启用了audio,AirPlay和图片中的背景模式。 我已经创build了AVPlayerViewController ,如下所示: // Create the view controller and player let moviePlayerViewController: AVPlayerViewController = AVPlayerViewController() let moviePlayer = AVPlayer(url: videoUrl!) moviePlayer.allowsExternalPlayback = true moviePlayer.usesExternalPlaybackWhileExternalScreenIsActive = true // […]

UICollectionViewCell中的AVPlayerViewController错误?

在我的UICollectionView中,我有一个单元格。 这是我的cellForItemAtIndexPath func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var videoCell = collectionView.dequeueReusableCellWithReuseIdentifier("cellVideo", forIndexPath: indexPath) as? CollectionViewCell let post = self.arrayOfDetails[indexPath.row] var myUrl = post.image // post.image is image url let fileUrl = NSURL(string: post.image) aPlayer = AVPlayer(URL: fileUrl) moviePlayerController.player = aPlayer moviePlayerController.view.frame = CGRectMake(8, 8, videoCell!.frame.size.width-16, 310) moviePlayerController.videoGravity = AVLayerVideoGravityResizeAspectFill moviePlayerController.view.sizeToFit() moviePlayerController.showsPlaybackControls […]

如何对AVPlayer的播放和暂停操作执行一些操作?

我用AVPlayer在我的swift应用程序上播放video。 我想在video的中间放置一个播放button(自定义button)。 我知道如何玩点击button暂停video。 当video从默认button播放/暂停时,我找不到如何显示/隐藏自定义button? video播放/暂停时是否有任何听众或某些事件触发? 我也想从默认控制中隐藏“audio和字幕”图标。