No Visible interface for 'AVAudioPlayer declares the selector initWithUrl:'


I am trying to play a button click sound,also that i should be able to manage click sound along with volume button.

What i have done is Added AVFoundationFramework to project,

in .h file

#import <AVFoundation/AVAudioPlayer.h> #import <AVFoundation/AVFoundation.h>

in .m file under button click method

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"mp3"]; NSURL *soundUrl = [NSURL fileURLWithPath:soundPath]; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithURL:soundUrl]; [player play];

but i get the above error.Any help would be appreciated.


It's <a href="https://developer.apple.com/library/ios/DOCUMENTATION/AVFoundation/Reference/AVAudioPlayerClassReference/Reference/Reference.html#//apple_ref/occ/instm/AVAudioPlayer/initWithContentsOfURL%3aerror%3a" rel="nofollow">"initWithContentsOfURL:"</a> not "initWithURL:".

As in:

AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl];


  • How to correctly stop and remove an audioTapProcessor in iOS11
  • jquery mobile and Durandal
  • Piping output from aplay to arecord in centos
  • Handling interruptions in Sprite Kit - can't get sound effects via [SKAction playSoundFileNamed
  • Parse Push Notification Include Users TimeZone in Push-Time
  • Controling the Volume of an Audio Clip in Java 1.4
  • iOS Development: What are some reasons that [[self navigationController] viewControllers]; would ret
  • How to play MPEG-DASH with AVPlayer?
  • Code to record from webcam or default video and audio devices in asp.net?
  • React Native: Native Android UI component with JWPlayer shows no video image
  • StartForeground Bad Notification Error
  • C# String Filepath Question
  • How to implement AVAudioPlayer Inside Singleton Method?
  • HttpClient with WebView
  • three.js WebVR example code works on threejs.org but not on my local server
  • Disabling sound of embedded flash object with html
  • Why isn't my “Fizz Buzz” test in R working?
  • Does Apportable support to build library binary (.a/.so)?
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • Switching to Release Build causes runtime error in Web Reference
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Why winpcap requires both .lib and .dll to run?
  • QuartzCore.framework for Mono Develop
  • Return words with double consecutive letters
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Data Validation Drop Down Box Arrow Disappearing
  • Python: how to group similar lists together in a list of lists?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal