avplayer

AVPlayer noise issue after playing a while

不羁岁月 提交于 2019-12-08 09:37:09
问题 I use AVPlayer to play streamed network audio. I modify the sample code AVPlayerDemo from Apple The work is good. But after play for a while, the player has noise sound, someone call "scratch sound". I checked the code, anytime my player has only one AVPlayer object, one AVPlayerItem objet for marking, one AVURLAsset object for marking. I use "alloc, retain, realease" explicitly, so it's not problem of memory overhead. Can you know any reason cause the noise sound? Thank you 回答1: I am having

Reacting to ControlCenter events when using AVPlayer for HLS audio playback

て烟熏妆下的殇ゞ 提交于 2019-12-08 08:37:12
问题 I am looking for a way to handle the play/pause events from the iOS ControlCenter when playing audio (HLS) using AVPlayer. I have it all working, but it is based on "named" notifications which are not exposed in the header files. Is there an "official" way to do this? Currently the following code works: - (void) removeControlCenterNotifications { [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; } - (void) addControlCenterNotifications { [[UIApplication sharedApplication]

AvAudioSession won't work in iOS7?

匆匆过客 提交于 2019-12-08 06:26:04
问题 #import "SctreamAudioViewController.h" #import <AVFoundation/AVFoundation.h> #import "SecondViewController.h" @interface SctreamAudioViewController () @property (nonatomic, strong) AVPlayer *player; @end @implementation SctreamAudioViewController #define STREAM @"http://localhost/audio.mp3" - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory

Can't hide status bar in AVPlayerViewController's portrait mode

不问归期 提交于 2019-12-08 06:15:06
问题 I'm developing an app that first presents a UICollectionView with a bunch of buttons that modally open a subclass of AVPlayerViewController with a custom "Over Full Screen" segue. UIViewControllerBasedStatusBarAppearance is set to YES in my Info.plist. Here's a small (had to zoom out, sorry) screenshot of all the view controllers in Interface Builder: The segue was defined in IB. When the user taps a collection view cell, I use performSegueWithIdentifier() to, well, perform the segue. The

Auto Layout view to fullscreen on rotate

落爺英雄遲暮 提交于 2019-12-08 05:30:13
问题 I am writing a video playing app. The app has information about the app below the video while watching in portrait mode, but when the app is turned to landscape I want the video to go full screen. Unfortunately when the app is turned to landscape the bottom view constrains the video view from expanding all the way from the top to the bottom even though I've turned the height constraint to priority == 1. Portrait Mode: Landscape Mode: I've tried hiding the lower view, but that throws the whole

Can't Play AVPLayer Local Video from

不问归期 提交于 2019-12-08 04:37:56
问题 So I am building a custom video player using AVFoundation - AVPlayer and AVPlayerLayer . Currently, all I want the player to do is play a video in the asset library with a hardcoded url to that video. I would like this to be contained in a SubClass of UIView so I can use it all around my app. Here is my code so far: CUPlayer.h : @interface CUPlayer : UIView { AVPlayer *player; AVPlayerLayer *playerLayer; AVPlayerItem *item; NSURL *url; } @property(nonatomic) UIViewAutoresizing

Resume AVPlayer stream playback last sample

若如初见. 提交于 2019-12-08 03:59:52
问题 I am trying to use the native player (AVPlayer) to reproduce a live stream on iOS. However, I have trouble resuming the playback. When I stop the playback and resume it after few seconds, the playback starts from the moment I paused instead of reproducing the current (last) sample of the live stream. Is there a way to get the last sample, o configure AVPlayer to reproduce from last sample when tapping on Play Button? 回答1: My solution is based on denying user to keep the player paused. This is

AVPlayer exit fullscreen on finish playing

放肆的年华 提交于 2019-12-08 02:50:00
问题 I am using a AVPlayer to show some video streams (with a fixed length). The problem is when the content is finished the player (if it has been set to fullscreen by the user) still remains in fullscreen. Any way to make the player go to it's minimized state immediately after the content is finished playing? 回答1: To add on to longilong's answer, You could dismiss the video player with dismissViewControllerAnimated in the itemDidFinishPlaying function. You should also remember to remove the

AVPlayer Skips the Beginning of a Video

瘦欲@ 提交于 2019-12-08 01:48:23
问题 I'm having an issue with AVPlayer skipping the first 0.5 seconds of a video I'm playing when I attempt to play it immediately after pre-rolling. First, I create the player: self.videoPlayer = [[AVPlayer alloc] init]; Then, I add the player item to the player and add an observer to check and see when the item is ready: [self.videoPlayer addObserver:self forKeyPath:@"currentItem" options:0 context:kBLCurrentPlayerItemStatusContext]; [self.videoPlayer replaceCurrentItemWithPlayerItem:self

Jumpy UISlider when scrubbing - Using UISlider with AVPlayer

怎甘沉沦 提交于 2019-12-08 01:16:31
问题 I am using AvPlayer and am trying to set up a slider to allow scrubbing of audio files. Im having a problem with the slider jumping all over the place when its selected. It then goes back to the origin position for a second before going back to the location it was dragged to. You cant see my cursor on the Gif, but the smooth elongated drags are me moving the knob, then the quick whips are the slider misbehaving. Ive spent hours googling and combing through Stack Overflow and cant figure out