On Oct 5, 2010, at 6:23 AM, Devarshi Kulshreshtha wrote:

> I am trying to play a .mp3 file on click of a button using this code:
> 
> NSString 
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html>
> *audioFilePath=[[audioInputTextField stringValue]
> stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];NSURL
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html>
> *audioUrl = [[NSURL
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html>
> alloc] initWithString:audioFilePath];
> QTMovie* soundToPlay = [[QTMovie alloc] initWithURL:audioUrl
> error:nil];[soundToPlay play];
> 
> 
> Here user is expected to enter a valid url for an audio file in text
> field and then click button next to it to play, but it is not working
> for me ie. no audio gets played :(
> 
> Can anyone suggest me, if I am doing anything wrong?

Are you sure the user is entering a valid URL and not a file path? If it's a 
path, then you need to use -initFileURLWithPath: and not -initWithString:, and 
the path shouldn't be percent-escape encoded.

Have you tried passing a pointer to an NSError pointer into the 
-initWithURL:error: message? The error you get back, if any, should tell you 
why it's not working.

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to