BSD

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • NSSound and private embedded frameworks

    2 answers - 1737 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi all,
    I have a private embedded framework that contains code, several image
    files and several WAV files. In turn, this framework is inside of
    the a Cocoa application bundle.
    There are two .wav files: insert.wav and eject.wav which are part of
    the framework, and are in the BP.framework/Resources folder. The
    BP.framework folder in turn is located in the applications Contents/
    Frameworks folder (hence it is "private embedded")
    I've followed the instructions on http://rentzsch.com/cocoa/
    embeddedFrameworks and so far almost everything is working EXCEPT for
    sound.
    In a routine in the framework code, I have the following lines:
    insertSound = [NSSound soundNamed:@"insert"];
    NSLog(@"Insert Sound = %X", insertSound);
    The log shows that insertSound is 0 (nil) when I run the
    application. However, if I copy eject.wav and insert.wav from
    to Contents/Resources, the
    Log shows that the insertSound pointer is not nil and the sound
    actually works.
    The framework's NIB file shows the 'insert' and 'eject' sounds in the
    Sounds tab, so the NIB file "sees" them, but it appears that NSSound
    is only looking in Contents/Resources and not the framework's
    Resources folder for sounds.
    Could someone possibly shed some light on why this might be
    happening? If I haven't provided enough information, please let me
    know.
    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com
    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.1 | | 2678 bytes | |

    Boisy, you may want to try the following.

    First, get the NSBundle object for your framework using :

    NSBundle *myFrameworkBundle = [NSBundle
    bundleWithIdentifier:@"com.myframework.name"];

    Then get the path to the sound file using

    NSString *soundPath = [myFrameworkBundle
    pathForResource:@"MySoundName" ofType:@"wav"];

    Make sure the sound file ends in the .wav extension. That sound path
    should be a complete path whether using the framework or the
    application. Use that path to initialize your NSSound object - (id)
    initWithCFile:(NSString *)path byReference:(BL)byRef
    -Phil

    Jan 2, 2006, at 2:32 AM, Boisy Pitre wrote:

    Hi all,

    I have a private embedded framework that contains code, several
    image files and several WAV files. In turn, this framework is
    inside of the a Cocoa application bundle.

    There are two .wav files: insert.wav and eject.wav which are part
    of the framework, and are in the BP.framework/Resources folder.
    The BP.framework folder in turn is located in the applications
    Contents/Frameworks folder (hence it is "private embedded")

    I've followed the instructions on http://rentzsch.com/cocoa/
    embeddedFrameworks and so far almost everything is working EXCEPT
    for sound.

    In a routine in the framework code, I have the following lines:

    insertSound = [NSSound soundNamed:@"insert"];
    NSLog(@"Insert Sound = %X", insertSound);

    The log shows that insertSound is 0 (nil) when I run the
    application. However, if I copy eject.wav and insert.wav from
    to Contents/Resources,
    the Log shows that the insertSound pointer is not nil and the sound
    actually works.

    The framework's NIB file shows the 'insert' and 'eject' sounds in
    the Sounds tab, so the NIB file "sees" them, but it appears that
    NSSound is only looking in Contents/Resources and not the
    framework's Resources folder for sounds.

    Could someone possibly shed some light on why this might be
    happening? If I haven't provided enough information, please let me
    know.
    --

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40phildow.net

    This email sent to dev (AT) phildow (DOT) net

    Do not post admin requests to the list. They will be ignored.
    Cocoa-dev mailing list (Cocoa-dev (AT) lists (DOT) apple.com)
    Help/Unsubscribe/Update your Subscription:
    %40developershed.com

    This email sent to bsdarchive (AT) developershed (DOT) com
  • No.2 | | 907 bytes | |

    2006/1/3, Philip Dow <dev (AT) phildow (DOT) net>:
    Boisy, you may want to try the following.

    First, get the NSBundle object for your framework using :

    NSBundle *myFrameworkBundle = [NSBundle
    bundleWithIdentifier:@"com.myframework.name"];

    Then get the path to the sound file using

    NSString *soundPath = [myFrameworkBundle
    pathForResource:@"MySoundName" ofType:@"wav"];

    A better idea would be to use:

    NSString *soundPath = [myFrameworkBundle pathForSoundResource: @"MySoundName"];

    That way, it will work even if the file's format/type is changed (to
    aiff, mp3, whatever)

    Make sure the sound file ends in the .wav extension. That sound path
    should be a complete path whether using the framework or the
    application. Use that path to initialize your NSSound object - (id)
    initWithCFile:(NSString *)path byReference:(BL)byRef

Re: NSSound and private embedded frameworks


max 4000 letters.
Your nickname that display:
In order to stop the spam: 5 + 4 =
QUESTION ON "BSD"

EMSDN.COM