Note that there are some explanatory texts on larger screens.

plurals
  1. POAudio file is not playing in iPhone/iOS
    primarykey
    data
    text
    <p>I need to play a audio file(mp3) that i am fetching from <a href="http://fundamentalalvarado.com/audio.php" rel="nofollow">json</a> in a table view, on clicking row respective song path is passing to another UIView..on loading view it should play.</p> <p>I know there is a lot of similar problem pasted over internet and i tried many ways nothing worked for me.</p> <p>Here is the code snippet.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSError *error = nil; [[AVAudioSession sharedInstance]setCategory:AVAudioSessionCategoryAmbient error:&amp;error]; // audioFile--contains path-- // NSString *filePath = [[NSBundle mainBundle] pathForResource:audioFile ofType:@"mp3"]; NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:audioFile]; NSURL *url = [NSURL fileURLWithPath:filePath]; player = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&amp;error]; if([self.player prepareToPlay]) { NSLog(@"preparing"); } else { NSLog(@"some error"); } if([self.player play]) { NSLog(@"playing"); } NSLog(@"not playing"); NSLog(@"\n\nfile path-&gt; %@\n\n url-&gt; %@",filePath,url); } </code></pre> <p>Where <strong>player</strong> is an object of <strong>AVAudioPlayer</strong> class</p> <pre><code> @property (strong, nonatomic) AVAudioPlayer *player; </code></pre> <p>From above, Values coming from NSLog() are(for a particular row)</p> <pre><code> file path-&gt; /Users/ensignweb/Library/Application Support/iPhone Simulator/6.1/Applications/CE146654-3D1B-4F60-B37D-825267FD6EFB/Library/http:/www.fundamentalalvarado.com/assets/sermons/bible-doctrine-series/033113-pm-Doctrine of Creation vs The Lie of Evolution.mp3 url-&gt; file://localhost/Users/ensignweb/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/CE146654-3D1B-4F60-B37D-825267FD6EFB/Library/http:/www.fundamentalalvarado.com/assets/sermons/bible-doctrine-series/033113-pm-Doctrine%20of%20Creation%20vs%20The%20Lie%20of%20Evolution.mp3 </code></pre> <p>When i used NSBundle filePath was null so i commented it.Even at the end <strong>If Loop</strong> escaping to <strong>else</strong>.I guess there could be the problem.</p> <p><strong>Please help me out.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload