在iOS SDK-AVPlayer中手动选择视频质量的HLS流?
我们已经通过Avplayer实施了HLS流媒体 fileURL = [NSURL URLWithString:@"https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8"]; avAsset = [AVURLAsset assetWithURL:fileURL]; AVPlayerItem *avPlayerItem =[[AVPlayerItem alloc]initWithAsset:self->avAsset]; self->avPlayer = [AVPlayer playerWithPlayerItem:avPlayerItem]; 它会根据网络速度自动选择视频质量,我们还需要通过选择用户选择手动选择视频质量.但是我们无法手动选择媒体文件(质量1080p,720p,270p等). 如果有人知道使用手动质量选择的HL
12 2023-05-22
编程技术问答社区
播放来自Parse.com的音频
我正在尝试播放我保存在解析上的音频文件.我正在从pffile中获取我保存的对象到解析的URL.当我运行应用程序时,Avplayer不会产生音频.我测试了Avplayer是否在下面的第一个代码片段中播放,它打印出"播放",这意味着玩家正在播放,但没有音频.我还尝试为Avplayer设置卷,但这无济于事.不明白为什么有人想帮助我,为什么它不会玩. Audio File URL: http://files.parsetfss.com/292B6F11-5FEE-4BE7-B317-16FD494DFA3D/TFSS-CCCCCCC3A843-967B-4773B92E 此代码在播放时停止Avplayer: if (player.rate > 0) && (player.error == nil) { // player is playing println("Playing") } else {
0 2023-05-20
编程技术问答社区
准确地寻找,而不是短两秒,在AVPlayer中
我正在一个可可应用中使用Avplayer,并且我已经实现了一个跳到视频末尾的命令. 问题是,Avplayer并没有寻求我告诉的地方. 例如,我拥有的视频之一是4分14秒.当我寻求结束时,Avplayer的目标是4分12秒,短短秒.如果我打球,玩家将玩两秒钟,然后到达末端. 我的第一个尝试是: [self.player seekToTime:self.player.currentItem.duration]; 我已经将其切换为: [self.player seekToTime:self.player.currentItem.duration toleranceBefore:kCMTimePositiveInfinity toleranceAfter:kCMTimeZero]; 一个人都没有比另一个更好的工作. 我也尝试寻求kCMTimePositiveInfinity.那只是忽略了我. 播放器是否已经加载了
0 2023-05-14
编程技术问答社区
如何在AVPlayer中强制使用横向模式?
我正在寻找一种强迫Avplayer(视频)以仅以景观模式显示自己的方法(左侧的主页按钮).这可能吗? 编辑:尝试添加 PlayerviewController.supportedInterfaceorientations = .landscapeleft 有错误消息 "不能分配给属性:'支持Interfaceorientations'是一个唯一的属性" import AVKit import AVFoundation UIViewController { var videoPlayer = AVPlayer() var playerViewController = AVPlayerViewController() override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) play() } func play() {
2 2023-05-14
编程技术问答社区
Mac OS AVPlayer Xcode 10.2.1 swift 5.0.1无法工作
我正在尝试为Mac OS 10.14.5 Xcode 10.2.1 Swift 5.0.1创建一个简单的Avbasicplayback.我使用了Avplayer,它正在抛出一些错误. Mac OS开发的新手无法弄清楚什么问题.我在线检查了很多文档. 我将nsapptransportsecurity添加到info.plist文件下面. . info.plist文件 CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE)
0 2023-05-12
编程技术问答社区
从AVPlayerItemVideoOutput到openGL Texture的最佳路径
一直在拔出头发,试图找出当前的最佳路径从Avfoundation Videos到OpenGlTexture,我发现的大部分与iOS有关,我似乎无法使其在OSX中效果很好. 首先,这是我设置视频输出的方式: NSDictionary *pbOptions = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:kCVPixelFormatType_422YpCbCr8], kCVPixelBufferPixelFormatTypeKey, [NSDictionary dictionary], kCVPixelBufferIOSurfacePropertiesKey, nil]; self.playeroutp
0 2023-05-10
编程技术问答社区
AVPlayer边界时间观察器偶尔无法发射
我正在使用avplayer的-addboundarytimeoserververimes:queue:using block:在视频中的特定时间执行某些代码(在这种情况下,我想要一个视频达到其持续时间时的un -hide a按钮.代码如下如下. : - (void)viewWillAppear:(BOOL)animated { ... _player = [AVPlayer playerWithURL:videoURL]; AVPlayerLayer *newPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:_player]; [newPlayerLayer setFrame:_videoView.bounds]; [_videoView.layer addSublayer:newPlayerLayer]; _observer = [_player addBoundaryTim
0 2023-05-07
编程技术问答社区
使用URL播放通知声音
我希望我的应用程序通过URL播放通知声音.我的自定义声音文件位于特定的工作URL.因此,我希望我的应用程序使用该链接将通知用户通知通知. 我已经尝试了AVPlayer,因为它通过url的检查此 AVPlayer我使用[self playselectedsong]调用[self playselectedsong] AppDelegate和viewDidLoad viewDidLoad的函数时,代码正在工作. . 每当通知到达带有音频文件URL的通知到达(didReceiveRemoteNotification),然后我添加到AVPlayer中时,声音不播放.仅显示文本通知. 解决方案 不,除非您在主捆绑包上有远程通知,否则不可能在远程通知上播放声音. 对于iOS中的远程通知,您可以指定自定义声音 iOS播放时播放本地或远程通知 应用.声音文件必须在客户端的主捆绑中 应用程序. 即使您在主捆绑包上添加声音文件,该文件也不能超过30秒 播放时的自定
0 2023-05-07
编程技术问答社区
iOS从avplayer获取音频时长
我是iOS的新手,我有一个包含在线音频播放器的应用程序.我需要获得音频的总持续时间.我尝试了很多,但是所有代码都返回 nan 或 0 持续时间.获得音频总持续时间的最佳方法是什么?? 我的代码 NSString *songUrl = @"http://9xmusiq.com/songs2/tamil/Kaatru%20Veliyidai/Azhagiye%20%5bStarmusiq.cc%5d.mp3" AVURLAsset *asset = [AVURLAsset assetWithURL:[NSURL URLWithString:songUrl]]; AVPlayerItem *playerItem1 = [AVPlayerItem playerItemWithAsset:asset]; AVPlayer *player1 = [AVPlayer playerWithPlayerItem:playerItem1]; AVPlayerLayer *playerLayer
2 2023-05-07
编程技术问答社区
AVPlayer不能播放带有动态URL的流媒体广播
iOS上的Avplayer在执行此操作时 都可以完美地播放广播 AVPlayer *player; player =[[AVPlayer alloc] initWithURL:[NSURL URLWithString:@"http://kantipur-stream.softnep.com:7248"]]; [player play] ,但是当我使用称为链接的NSString变量时,它不会播放任何收音机来保存不同收音机的URL字符串,例如 AVPlayer *player; player =[[AVPlayer alloc] initWithURL:[NSURL URLWithString:link]]; [player play] 链接从XML文档中获取并解析. 我不明白问题是什么. 解决方案 尝试此代码....它对我有用... NSString *string=@"http://kantipur-stream.softnep.com:7248";
0 2023-05-07
编程技术问答社区
播放某些项目后,AVPlayer无法播放
我正在构建一个简单的游戏,我需要在当地的捆绑包中向用户显示2个视频.我只想在我的ViewController上播放该视频.我的代码是: let playerItem = AVPlayerItem(URL: NSURL.fileURLWithPath("\(vdoPath)")) //vdoPath will be random of that two local video files from bundle let player = AVPlayer(playerItem: playerItem) let playerViewController = AVPlayerViewController() playerViewController.player = player playerViewController.view.backgroundColor = UIColor.clearColor() playerViewController.showsPlaybackContro
2 2023-05-06
编程技术问答社区
AVPlayerViewController没有加载远程URL
我正在尝试在AVPlayerViewController中播放远程MP4视频: self.vcVideo = [[AVPlayerViewController alloc] init]; self.vcVideo.player = [AVPlayer playerWithURL:[NSURL URLWithString:videoURL]]; [self presentViewController:self.vcVideo animated:YES completion:^{ [self.vcVideo.player play]; }]; 显示了视图控制器,但播放按钮已禁用: 这在iOS 9. 上 解决方案 在IOS9中,更改了IOS9安全策略.在您的日志中,您应该看到有关安全性的信息.我相信您的远程视频URL是HTTP而不是HTTP.您应该将这些行添加到PLIST文件中. NSAppTransportSecurity
2 2023-05-06
编程技术问答社区
AVQueuePlayer在后台播放多个音轨 iOS5
我使用avqueeplayer在背景中播放多个项目.代码在ios4中的工作非常完美.在ios5中,avqueeplayer改变了其行为,因此播放器在第一项结束后停止玩. 马特·加拉格尔(Matt Gallagher)在此 post 中. "从iOS 5开始,看来Avqueueplayer不再预先抢劫.它确实在iOS 4中的下一个曲目进行了预言." 所以我的问题是如何在ios5中使用Avplayer或AvqueEplayer在后台播放多个项目. 解决方案 马特·加拉格尔(Matt Gallagher)的答案在他的." 实际上,这对我没有帮助. 所以我的解决方案是: [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 我无法解释原因,但是在添加新的AvplayerItem之前提出的这一代码使我的代码工作. 对于那些在背景中添加下一个曲目并使用方法 的人也适用
4 2023-05-06
编程技术问答社区
如何在remoteControlledEvents中选择下一首歌曲
我正在使用AVPlayer可以在其中控制播放,通过双击主页按钮或技术术语remoteControlledEvents暂停功能.我想知道如何实现它,以便我可以在remoteControlledEvents中进入下一个曲目. 谢谢 -(void)remoteControlReceivedWithEvent:(UIEvent *)event { switch (event.subtype) { case UIEventSubtypeRemoteControlTogglePlayPause: if (avplayer.rate == 0.0) { [avplayer play]; } else { [avplayer pause]; } break; case UIEventSubtypeRemoteControlPlay: [avplayer play]; b
0 2023-05-06
编程技术问答社区
我怎样才能把正在用AVPlayer播放的歌曲和一个WAV文件同时录下来呢?
我正在开发一个应用程序,我必须在其中同时录制歌曲和WAV文件.我正在播放iPod音乐库中的歌曲,在视图控制器上,我在单击上放置了一个按钮wav文件启动,但是当我开始使用avaudiorecorder录制时,我的wav文件停止工作. 这是我的iPod音乐库的代码: - - (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) collection { MPMediaItem *item = [[collection items] objectAtIndex:0]; NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL]; [self dismissModalViewControllerAnimated: YES]; // Play the item
2 2023-05-06
编程技术问答社区
带有自定义覆盖层的AVPlayerViewController
从mpmovieplayer迁移到avkit,使我陷入了阻止问题. 我需要在AvplayerviewController上显示自定义tableview. 我可以这个表观视频 [self.avVideoPlayer.contentOverlayView addsubiew:self.mycustomTableView] 可见,但没有收到任何点击/滑动事件. 有什么想法为什么会发生这种情况,或者如何在全屏模式下即使在接收触摸事件的地方添加表视图? 解决方案 [self.view addSubview:btn]; 这将在最小化的播放器中添加按钮. 现在,对于全屏方案,您需要为视频添加一个观察者,这是我的代码: [self.avVideoPlayer addObserver:self forKeyPath:@"videoBounds" options:NSKeyValueObservingOptionNew | NSKeyValueObserv
0 2023-05-06
编程技术问答社区
在使用AVPlayer时,如何开始下一首歌曲或识别歌曲已完成?
如何立即使用Avplayer开始下一首歌?我有从MPMediaItemCollection中的iPod库中选择的歌曲集. 现在,我如何使用Avplayer作为一个一个人播放的歌曲列表? 解决方案 为了回答您的第一个问题,您可以使用与 相同的通知. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(songFinished:) name:AVPlayerItemDidPlayToEndTimeNotification object:[yourAVPlayer currentItem]]; -(void)songFinis
0 2023-05-06
编程技术问答社区
Mojave/MacOS 10.14.0。[AVPlayerItem duration]总是不确定的
我正在尝试使用以下代码读取本地存储的音频文件的持续时间: #import #import #import 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
0 2023-05-06
编程技术问答社区
iOS8中的AVPlayerItem addobserver问题
嗨,我正在使用avplayer在我的uitaiteviewcell上播放视频,它在iOS 7上工作正常,但是在iOS8中,它崩溃了,以下错误. 'An instance 0x7c01b000 of class AVPlayerItem was deallocated while key value observers were still registered with it. 这是我的代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ......... ......... if(cell.videoPlayer!= nil && cell.videoPlayer.currentItem != nil)
2 2023-05-06
编程技术问答社区
如何在iOS中用AVPlayer实现4.0的播放率?
player.rate = 4.0对我不起作用. 使用AVPlayer实现4.0的好方法,还是有更好的方法? 解决方案 使用[AVComposition scaleTimeRange:toDuration:]产生快速运动AVAsset. float rate = 4.0; AVAsset *asset = [AVAsset assetWithURL:someURL]; AVMutableComposition *composition = [AVMutableComposition composition]; NSError *error = nil; [composition insertTimeRange:CMTimeRangeMake(kCMTimeZero, asset.duration) ofAsset:asset atTime:kCMTimeZero error:&err
0 2023-05-06
编程技术问答社区