avplayer

AVAudioPlayer Doesn't play the songs inside the folders?

六月ゝ 毕业季﹏ 提交于 2019-12-10 22:32:15
问题 I used this code to play songs it is not playing the songs inside the folders or folders of folders except the Documents directory. NSString *songname=[NSString stringWithFormat:@"%@",songArray[songIndex]]; NSLog(@"songname:%@",songname); NSString* saveFileName = songname; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent

make AVPlayer fill the entire screen

泪湿孤枕 提交于 2019-12-10 22:11:25
问题 I have an app where I'd like a video to play in the background of a single view. What I did is create an AVPlayer , add that to an AVPlayerLayer and add that as a sublayer to my view. Then I set the frame and the videoGravity property: self.player = AVPlayer(url: URL(fileURLWithPath: path)) let playerLayer = AVPlayerLayer(player: self.player) self.layer.addSublayer(playerLayer) playerLayer.frame = self.bounds playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill Now the video plays,

iOS: bug in AVPlayerItem when receiving `304 Not Modified` response

只谈情不闲聊 提交于 2019-12-10 21:50:47
问题 This is a very weird bug. I have a tableView with each cell using an AVPlayer to stream a video from a remote server (think a Vine-like timeline). So when I scroll, the cells that get reused reconfigure their player with the new video. The problem is: if I scroll back and forth very fast, getting the same video in and out of the screen, the request sent by the AVPlayer eventually changes, to include the HTTP Headers If-None-Match and If-Modified-Since , which are not there the rest of the

AVPlayer with one video tracks and multiples audio tracks

老子叫甜甜 提交于 2019-12-10 20:27:54
问题 I'm trying to make a player in my App capable to have one video tracks and multiples audio tracks (for differents languages). I've done this but the player won't launch : AVMutableComposition *composition = [AVMutableComposition composition]; AVURLAsset* videoAsset = [[AVURLAsset alloc]initWithURL:urlVideo options:nil]; AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; NSError* error =

How to show my AVPlayer in a VStack with SwiftUI

被刻印的时光 ゝ 提交于 2019-12-10 18:50:00
问题 I have created a simple AVPlayer. (If I didn't create it correctly, please help me fixing it... 😀 ) I want to display it in my VStack with swift ui, but I'm kind of stuck... If at least there was the AVPlayer View component in the library, it would have been easier, but I didn't found it in the library... 😔 Here is my code in the ContentView.swift : // // ContentView.swift // test // // Created by Francis Dolbec on 2019-06-26. // Copyright © 2019 Francis Dolbec. All rights reserved. // import

Detect if AVPlayerViewController is playing video or buffering and add overlay to the player

孤街浪徒 提交于 2019-12-10 15:24:01
问题 I have to detect whether the video is in playing or buffering mode.I am loading the video from a URL. I have tried the below code and I am able to track after once the video has started playing, but not when it is in buffering state. Also, I want to add an overlay view in my player. I have tried to add the overlay in AVPlayer but when in full screen mode the overlay disappears. Need some suggestions. Thanks in advance. Below is my code: let playerAV = AVPlayerViewController() var player =

Error Domain=NSOSStatusErrorDomain Code=560030580 “The operation couldn’t be completed. (OSStatus error 560030580.)”

人走茶凉 提交于 2019-12-10 15:04:51
问题 I was using AVPlayer to play online mp3 stream ! When I pause the player [AVPlayer pause]; AVAudioSession *session = [AVAudioSession sharedInstance]; session.delegate = nil; NSError *error = nil; [session setActive:NO error:&error]; NSLog([error description]); I met the error , Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)" Can anyone tell me why and how to resolve it? Thank you very much!! 回答1: I encounter this problem too

AVPlayerStatus vs AVPlayerItemStatus

99封情书 提交于 2019-12-10 14:09:06
问题 The issue is that player.status returns AVPlayerStatusReadyToPlay a full 2 seconds before player.currentItem.status returns AVPlayerItemStatusReadyToPlay . Does anyone have any helpful explanations as to why this is happening? This is just sample code to show the basic idea of what's happening so if there are any typos or whatever please ignore them. - (void) someMethod { player = [[AVPlayer alloc] initWithURL:someValidURL]; [player play]; NSTimer *timer = [NSTimer timerWithTimeInterval:0.1

AVPlayerLooper black flash after each iteration

半世苍凉 提交于 2019-12-10 13:14:19
问题 I am using a sample code from Apple to play a video on a UICollectionViewCell background. I'm using AVPlayerLooper , since it is a iteration of the same video. My problem here is that when the video reaches the end, it shows a slight black-bip screen flash, maybe it is seeking the video to 0 time, I'm not sure. Here's the code: Protocol by Apple protocol Looper { init(videoURL: URL, loopCount: Int) func start(in layer: CALayer) func stop() } Player Looper Class provided by Apple // Code from

AVPlayerItemDidPlayToEndTimeNotification only works if forced

♀尐吖头ヾ 提交于 2019-12-10 11:56:20
问题 I been searching everywhere and I still can't find a solution to this problem. I have a AVQueuePlayer for a radio app that I am making. It has about 20 AVPlayerItems queued at a time. I added the AVPlayerItemDidPlayToEndTimeNotification observer to each one of those items. The notification gets fired and executes the code to remove key observers for metadata and status so it doesn't crash and advances to next item in the queue. However it doesn't want to play. There is no error, the status is