Implementa el uso simple de sonidos , sin necesidad de acudir al Quicktime .No es indicado para reproducir musica .
Code: Select all
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
static PHB_SYMB symFMH = NULL;
@interface FWSound : NSSound
- (void) sound:(NSSound *)sound didFinishPlaying:(BOOL)playbackSuccessful
@end
@implementation FWSound
- (void) sound:(NSSound *)sound didFinishPlaying:(BOOL)playbackSuccessful
{
if playbackSuccessful
{
/*
if( symFMH == NULL )
symFMH = hb_dynsymSymbol( hb_dynsymFindName( "_FMH" ) );
hb_vmPushSymbol( symFMH );
hb_vmPushNil();
hb_vmPushLong( ( LONG ) hWnd );
hb_vmPushLong( WM_BTNCLICK );
hb_vmPushLong( ( LONG ) self );
hb_vmDo( 3 );
*/
NSLog( @"Termina el sonido" );
}
}
@end
HB_FUNC( SOUNDCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
FWSound * sound = [[FWSound alloc] initWithContentsOfFile: string byReference:YES];
[ sound setDelegate : sound ];
hb_retnl( ( LONG ) sound );
}
HB_FUNC( SOUNDCREATEBYNAME )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
FWSound * sound = [[FWSound alloc]soundNamed: string ];
[ sound setDelegate : sound ];
hb_retnl( ( LONG ) sound );
}
HB_FUNC( SOUNDPLAY )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
hb_retl([sound play]);
}
HB_FUNC( SOUNDISPLAYING )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
hb_retl([sound isPlaying]);
}
HB_FUNC( SOUNDSTOP )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
hb_retl([sound stop]);
}
HB_FUNC( SOUNDPAUSE )
{
NSSound * sound = ( NSSound * ) hb_parnl( 1 );
hb_retl( [sound pause] );
}
HB_FUNC( SOUNDRESUME )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
hb_retl( [sound resume] );
}
HB_FUNC( SOUNDVOLUMEN )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
[sound setVolume : ( hb_parnl( 2 )/100,0 ) ];
}
HB_FUNC( SOUNDEND )
{
FWSound * sound = ( FWSound * ) hb_parnl( 1 );
[sound deallocate ];
}