Questions tagged [avplayer]

An AVPlayer object is used to implement controllers and user interfaces for single- or multiple-item playback.

An AVPlayer object is used to implement controllers and user interfaces for single- or multiple-item playback.

3602 questions
21
votes
3 answers

AudioHardware.cpp:1200:AudioObjectRemovePropertyListener: AudioObjectRemovePropertyListener: no object with given ID 0

Working on a project in swift, where I'm trying to initiate the AVPlayer, and for some reason it trows me an exception saying AudioHardware.cpp:1200:AudioObjectRemovePropertyListener: AudioObjectRemovePropertyListener: no object with given ID 0.…
danu
  • 1,079
  • 5
  • 16
  • 48
21
votes
3 answers

How to get video size for HLS stream inside AVPlayer?

I am trying to get video resolution when playing hls stream. I have typical player init: let urlAsset = AVURLAsset(URL: currentVideoUrl) self.player=AVPlayer(playerItem: AVPlayerItem(asset:urlAsset)) ....... I use KVO and i try to get video size…
DixieFlatline
  • 7,895
  • 24
  • 95
  • 147
21
votes
4 answers

Audio playback progress as UISlider in Swift

I've seen some posts about accomplishing this in Objective-C but I've been unable to do the same via Swift. Specifically, I can't figure out how to implement addPeriodicTimeObserverForInterval in the below. var player : AVAudioPlayer! =…
allocate
  • 1,323
  • 3
  • 14
  • 28
21
votes
3 answers

How to detect when an AVPlayerItem is finished playing?

I've been looking through the AVPlayerItem and AVPlayer docs and there doesn't seem to be any callbacks for when the item is finished playing. I was hoping that there would be some sort of delegate callback that we can utilize or that…
3254523
  • 3,016
  • 7
  • 29
  • 43
20
votes
3 answers

AVPlayer error while playing on tvOS

I'm playing a video on tvOS using the following code: NSString *filePath = [[NSBundle mainBundle] pathForResource:name ofType:@"mov"]; NSURL *fileUrl = [NSURL fileURLWithPath:filePath]; self.player = [AVPlayer playerWithURL:fileUrl]; AVPlayerLayer…
Wojtek
  • 1,006
  • 11
  • 30
20
votes
4 answers

Swift: AVPlayer - How to get length of mp3 file from URL?

I'm process to build my first IOS app in swift and i get stuck in the question: How to get length (duration) of a music file when streaming ? I did research a lot and also write some line of codes for solve this problem but seem my code is not good…
Dai Bui
  • 313
  • 1
  • 2
  • 6
20
votes
4 answers

AVPlayer - Add Seconds to CMTime

How can I add 5 seconds to my current playing Time? Actually this is my code: CMTime currentTime = music.currentTime; I can´t use CMTimeGetSeconds() , because I need the CMTime format. Thank you for your answers... EDIT: How can I set a variable…
Lorenz Wöhr
  • 855
  • 3
  • 14
  • 22
19
votes
4 answers

Handle streaming events with AVPlayer

I'm building an app which plays an audio stream (from a webradio). I'm using AVPlayer for it. I'd like to know how you would handle AVPlayer's "buffering" when the connection is slow or when the user just clicked "play". I want to detect that…
Quentin Hayot
  • 7,786
  • 6
  • 45
  • 62
19
votes
3 answers

objectiveC/CMTime - convert AVPlayer.duration to milliseconds

I'm creating an app for playing a ringtone and I'd want to know the current time in milliseconds of the played ringtone every time. CMTime cTime = player_.currentTime; float currentTime = cTime.value / cTime.timescale; That currentTime here gets the…
nano
  • 2,511
  • 4
  • 25
  • 42
19
votes
5 answers

An AVPlayerItem cannot be associated with more than one instance of AVPlayer'

-(IBAction)play:(id)sender { thumbImageView.alpha=0.0; NSString *stringvideo=[NSString stringWithFormat:@"http://streaming-service",[[NSUserDefaults standardUserDefaults]valueForKey:@"VideoIdselected"]]; NSString *videoURLString =…
Andy Khatter
  • 191
  • 1
  • 1
  • 3
18
votes
2 answers

Play encrypted video with AVPlayer

I'm implementing an application that contains video player. For some reasons video files are encrypted with AES, and size of these files can be rather big to avoid loading it to RAM as one piece. I'm looking for some way to play it with…
Asya
  • 279
  • 2
  • 7
18
votes
7 answers

AVPlayer rate property does not work?

so it would appear that the only values that actually work are 0.0, 0.5, 1.0, and 2.0... i tried setting it to 0.25 since I want it to play at 1/4th of the natural speed, but it played it at 1/2 of the natural speed instead. can anyone confirm this?
bogardon
  • 896
  • 2
  • 10
  • 22
18
votes
9 answers

Done button click event in AVPlayerViewController

I want to play local video in AVPlayerViewController but did not find click event of Done button. My video is able to play in AVPlayerViewController but I did not find next button , previous button and done button click event.
Yogendra Patel
  • 813
  • 2
  • 8
  • 24
18
votes
6 answers

Video played with AVPlayer has grey line to top and sides on iPhone 6S Plus

This seems to be a device specific bug on only iPhone 6S Plus. Steps: Download AVPlayer demo sample code Adjust AVPlayerDemoPlaybackView.xib so that MPlayback View has margins around it Make content view color white 1px grey lines will appear at…
samwize
  • 25,675
  • 15
  • 141
  • 186
18
votes
4 answers

When Video plays using AVPLayer, it stops background music ios

I am playing video using AVPlayer, it stops iPhone's music which is on going in background. Please help me to resolve let item1 = AVPlayerItem.init(URL: NSURL(string:path)) player = AVPlayer(playerItem: item1) layer?.player = player; player?.play()
Zalak Patel
  • 1,937
  • 3
  • 26
  • 44