NSSound.m

NSSound.m

Postby mastintin » Fri Sep 03, 2010 10:40 am

Código escrito desde windows y sin probar aun , falta tambien el terminar la funcion delegada ...
Implementa el uso simple de sonidos , sin necesidad de acudir al Quicktime .No es indicado para reproducir musica .
Code: Select all  Expand view

#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 ];
}
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 3 guests