• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unable to play a .mp3 file directly using QTMovie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to play a .mp3 file directly using QTMovie


  • Subject: Re: Unable to play a .mp3 file directly using QTMovie
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 5 Oct 2010 09:30:17 -0600

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Unable to play a .mp3 file directly using QTMovie (From: Devarshi Kulshreshtha <email@hidden>)

  • Prev by Date: Re: Confused about floats
  • Next by Date: Re: Confused about floats
  • Previous by thread: Unable to play a .mp3 file directly using QTMovie
  • Next by thread: Checking for nil-return
  • Index(es):
    • Date
    • Thread