avplayer

How do I loop a video with AVFoundation without unwanted pauses at the end?

故事扮演 提交于 2019-12-05 22:32:03
I am trying to play a video clip that loops indefinitely. I am doing this the way Apple recommends; by setting up a notification that gets triggered by AVPlayerItemDidPlayToEndTimeNotification: @property(nonatomic) AVPlayer *videoPlayer; @property(nonatomic) AVPlayerItem *videoPlayerItem; -(void)loadVideo { NSURL *url = [[NSBundle mainBundle] URLForResource:filename withExtension:extension]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; NSString *tracksKey = @"tracks"; [asset loadValuesAsynchronouslyForKeys:@[tracksKey] completionHandler: ^{ dispatch_async(dispatch_get_main

How do I make AVCaptureSession and AVPlayer respect AVAudioSessionCategoryAmbient?

删除回忆录丶 提交于 2019-12-05 21:08:02
I'm making an app that records ( AVCaptureSession ) and plays ( AVPlayerLayer ) video. I'd like to be able to do this without pausing background audio from other apps and I'd like the playback to respect the mute switch. In the AppDelegate I have set AVAudioSessionCategoryAmbient , according to the docs this should: The category for an app in which sound playback is nonprimary—that is, your app can be used successfully with the sound turned off. This category is also appropriate for “play along” style apps, such as a virtual piano that a user plays while the Music app is playing. When you use

AVPlayer Can't Play

别等时光非礼了梦想. 提交于 2019-12-05 19:21:14
I want to play a remote mp3 with AVPlayer. I can't make it work and I can't see the reason why it doesn't work. Code: NSString *urlstr=@"..some link to a mp3" NSURL *url=[NSURL URLWithString:urlstr]; self.player = [[[AVPlayer alloc] initWithURL:url] retain]; [player play]; The link is valid. If I load it in a webView it plays right away. Please help. I have get a solution. Please try the following code: NSString *urlstr=@"http://www.3rdeyelab.com/mp3/mp3/tailtoddle_lo.mp3" NSURL *url=[NSURL URLWithString:urlstr]; AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url]; player = [

Can't play mp3 file over HTTP via AVPlayer

▼魔方 西西 提交于 2019-12-05 19:08:43
问题 I'm trying to play MP3 file via AVPlayer: let url = URL(string: "http://transom.org/wp-content/uploads/2004/03/stereo_40kbps.mp3?_=7")! let asset = AVURLAsset(url: url) let item = AVPlayerItem(asset: asset) let player = AVPlayer(playerItem: item) player.play() But I'm getting the next log: 2017-09-26 21:57:07.906598+0300 MyApp[7558:1177816] CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; "m_Limit" = "m_LimitAll"; "r_Attributes" = 1; sync = syna; }

AVPlayer Play, Pause and Buffering issue

时间秒杀一切 提交于 2019-12-05 19:07:56
My app plays a streaming video, but when it buffers, the player goes to the pause mode and I have to set it to play mode again manually, I have the following code in my AVPlayer class in order to handle this situation, but it does not work. In the ViewDidLoad method [playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil]; [playerItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil]; and then, handling the observers using the following methods - (void)observeValueForKeyPath:(NSString

AVPlayer seekToTime not working properly

。_饼干妹妹 提交于 2019-12-05 18:05:29
Im having a problem with seeking with AVPlayer.seekToTime, I have the time index that I want to seek to inside a scrollViewDidScroll method like this: func scrollViewDidScroll(scrollView: UIScrollView) { let offsetTime = scrollView.contentOffset.y * 0.1 self.playerController.player?.seekToTime(CMTime(seconds: Double(offsetTime), preferredTimescale: 10), toleranceBefore: kCMTimePositiveInfinity, toleranceAfter: kCMTimeZero) } But the video does not flow nice. For example, when you scroll I want the video to only to move forward like 0.01 of a second (the video I have is real short only about 2

How to play multiple videos smoothly in iOS in UICollectionView?

只谈情不闲聊 提交于 2019-12-05 16:19:09
I want to play multiple videos in infinite loop in my collection view. Each Video represent a cell. I am using ALAsset. I am playing this using AVPLayer but it's not loading and playing smoothly. Any Suggestions. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; CGRect attachmentFrame = CGRectMake(2, 2, cell.frame.size.width-4, cell.frame.size.height-4); ALAsset *asset = self.assets[indexPath

AVPlayer making extraneous http request prior to playback of HLS / AES-encrypted video

拈花ヽ惹草 提交于 2019-12-05 16:12:48
We're using AVPlayer on iOS 8.4 to play HLS, AES-encrypted video. Our .m3u8 files include the url of the license server, e.g.: EXT-X-KEY:METHOD=AES-128,URI="https://...." In our iOS application, we're using AVAssetResourceLoaderDelegate method resourceLoader:shouldWaitForLoadingOfRequestedResource: to intercept the request that gets sent by the AVPlayer (or some object within AVFoundation) to the license server. Within that method, we add a token (required by the license server) to the request's queryString. The license server receives the request with the token, returns the encryption key,

iOS AVAsset.duration is zero for HTTP live streaming but works for progressive

心不动则不痛 提交于 2019-12-05 15:23:09
问题 I have an iOS app that plays video from a HTTP Live stream "playlist.m3u8" and I have a custom player created using AVPlayer. To handle normal user interactions such as scrubbing i need to get the duration of the video, but for some reason on iOS 4.3 using xcode 4.0 when I call the following code I get a CMTime that when converted to seconds gives a NaN -- I know what it's doing because CMTimeValue = 0 and CMTimeScale = 0 which gives the NaN and the CMTimeFlags = 17 which is even more strange

How to play Facebook style video using UICollectionview

假如想象 提交于 2019-12-05 14:25:28
问题 I am attempting to play video in UICollectionview Cell using ZOWVideoPlayer . Video is playing perfectly but currently my collectionview is playing all visible videos. I want to play only single completely visible video. This means the current video that is not cropped by scrolling process (pixels are not off-screen, but fully visible). I also added code to check the complete visible cell in scrollview delegate methods but then my collectionview gets stuck for 1 or 2 seconds and then moves,