📄 hxclientplayer.mm
字号:
if ( pTitle && *pTitle ) { CFStringRef title = CFStringCreateWithCString( kCFAllocatorDefault, pTitle, GuessEncodingForCString( ( const unsigned char* ) pTitle ) ); return( [(NSString*)title autorelease] ); } } return [NSString string];}- (NSURL *)contextURL{ if ( m_pIClientPlayer ) { const char* pContextURL = m_pIClientPlayer->GetContextURL(); if ( pContextURL && *pContextURL ) { NSString* urlString = [NSString stringWithCString:pContextURL]; NSString* escapedURLString = ( NSString* ) CFURLCreateStringByAddingPercentEscapes( NULL, ( CFStringRef ) urlString, NULL, NULL, kCFStringEncodingUTF8 ); NSURL* contextURL = [NSURL URLWithString:escapedURLString]; // returns nil if pURL cannot be parsed. [escapedURLString release]; return contextURL; } } return nil;}- (BOOL)hasVisualContent{ return m_pIClientPlayer ? ( m_pIClientPlayer->HasVisualContent() ? YES : NO ) : NO;}- (NSSize)idealSize{ NSSize idealSize = NSZeroSize; if ( m_pIClientPlayer ) { INT32 siteIdealWidth, siteIdealHeight; m_pIClientPlayer->GetIdealSize( &siteIdealWidth, &siteIdealHeight ); idealSize.width = siteIdealWidth; idealSize.height = siteIdealHeight; } return idealSize;}- (SInt32)clipBandwidth{ return m_pIClientPlayer ? m_pIClientPlayer->GetClipBandwidth() : 0;}- (void)setSize:(NSSize)siteSize{ if ( m_pIClientPlayer ) { INT32 siteWidth = ( INT32 ) siteSize.width; INT32 siteHeight = ( INT32 ) siteSize.height; m_pIClientPlayer->SetSize( siteWidth, siteHeight ); }}- (void)drawSite:(SHXClientRect)siteRect{ if ( m_pIClientPlayer ) { m_pIClientPlayer->DrawSite( ( const HXxRect* ) &siteRect ); }}- (UInt16)groupCount{ return m_pIClientPlayer ? m_pIClientPlayer->GetGroupCount() : 0;}- (UInt16)currentGroup{ return m_pIClientPlayer ? m_pIClientPlayer->GetCurrentGroup() : 0;}- (BOOL)setCurrentGroup:(UInt16)groupIndex{ return m_pIClientPlayer ? ( ( 0 != SUCCEEDED( m_pIClientPlayer->SetCurrentGroup( groupIndex ) ) ) ? YES : NO ) : NO;}- (NSURL*)groupURLByIndex:(UInt16)groupIndex{ if ( m_pIClientPlayer ) { static const UInt32 kBufferSize = 4096; // XXXSEH: Is this big enough? Could call GetGroupTitle() twice; the first time will a nil buffer to obtain the necessary size. char urlBuffer[ kBufferSize ]; UInt32 usedBufferLength; if ( m_pIClientPlayer->GetGroupURL( groupIndex, urlBuffer, kBufferSize - 1, &usedBufferLength ) ) { NSString* urlString = [NSString stringWithCString:urlBuffer]; NSString* escapedURLString = (NSString*) CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef) urlString, NULL, NULL, kCFStringEncodingUTF8 ); NSURL* url = [NSURL URLWithString:escapedURLString]; // returns nil if pURL cannot be parsed [escapedURLString release]; return url; } } return nil;}- (NSString*)groupTitleByIndex:(UInt16)groupIndex{ if ( m_pIClientPlayer ) { static const UInt32 kBufferSize = 4096; // XXXSEH: Is this big enough? Could call GetGroupTitle() twice; the first time will a nil buffer to obtain the necessary size. char titleBuffer[ kBufferSize ]; UInt32 usedBufferLength; if ( m_pIClientPlayer->GetGroupTitle( groupIndex, titleBuffer, kBufferSize - 1, &usedBufferLength ) ) { CFStringRef title = CFStringCreateWithCString( kCFAllocatorDefault, titleBuffer, GuessEncodingForCString( ( const unsigned char* ) titleBuffer ) ); return [(NSString*)title autorelease]; } } return [NSString string];}- (NSArray*)groupsArray{ if ( m_pIClientPlayer ) { UInt16 groupCount = [self groupCount]; if ( groupCount > 0 ) { NSMutableArray* groupsArray = [NSMutableArray arrayWithCapacity:groupCount]; if ( groupsArray ) { for ( UInt16 groupIndex = 0; groupIndex < groupCount; ++groupIndex ) { NSString* groupTitle = [self groupTitleByIndex:groupIndex]; [groupsArray addObject:groupTitle]; } // NSLog([groupsArray description]); useful for seeing when the array of names changes return groupsArray; } } } return nil;}- (UInt16)volume{ return m_pIClientPlayer ? m_pIClientPlayer->GetVolume() : 0;}- (void)setVolume:(UInt16)volume{ if ( m_pIClientPlayer ) { m_pIClientPlayer->SetVolume( volume ); }}- (BOOL)isMuted{ return m_pIClientPlayer ? ( m_pIClientPlayer->IsMuted() ? YES : NO ) : NO;}- (void)mute:(BOOL)shouldMute{ if ( m_pIClientPlayer ) { m_pIClientPlayer->Mute( shouldMute ? true : false ); }}- (void)enableEQ:(BOOL)enable{ if ( m_pIClientPlayer ) { m_pIClientPlayer->EnableEQ( enable ? true : false ); }}- (BOOL)isEQEnabled{ return m_pIClientPlayer ? ( m_pIClientPlayer->IsEQEnabled() ? YES : NO ) : NO;}- (void)setEQGain:(SInt32)gain forBand:(int)band{ if ( m_pIClientPlayer ) { m_pIClientPlayer->SetEQGain( band, gain ); }}- (SInt32)eqGainForBand:(int)band{ return m_pIClientPlayer ? m_pIClientPlayer->GetEQGain( band ) : 0;}- (void)setEQPreGain:(SInt32)preGain{ if ( m_pIClientPlayer ) { m_pIClientPlayer->SetEQPreGain( preGain ); }}- (SInt32)eqPreGain{ return m_pIClientPlayer ? m_pIClientPlayer->GetEQPreGain() : 0;}- (void)enableEQAutoPreGain:(BOOL)enable{ if ( m_pIClientPlayer ) { m_pIClientPlayer->EnableEQAutoPreGain( enable ? true : false ); }}- (BOOL)isEQAutoPreGainEnabled{ return m_pIClientPlayer ? ( m_pIClientPlayer->IsEQAutoPreGainEnabled() ? YES : NO ) : NO;}- (void)setEQReverb:(SInt32)reverb{ if ( m_pIClientPlayer ) { static const SInt32 kIgnoreRoomSize = -1; m_pIClientPlayer->SetEQReverb( kIgnoreRoomSize, reverb ); }}- (SInt32)eqReverb{ SInt32 reverb = 0; if ( m_pIClientPlayer ) { SInt32 roomSize = 0; m_pIClientPlayer->GetEQReverb( &roomSize, &reverb ); } return reverb;}- (void)setEQRoomSize:(SInt32)roomSize{ if ( m_pIClientPlayer ) { static const SInt32 kIgnoreReverb = -1; m_pIClientPlayer->SetEQReverb( roomSize, kIgnoreReverb ); }}- (SInt32)eqRoomSize{ SInt32 roomSize = 0; if ( m_pIClientPlayer ) { SInt32 reverb = 0; m_pIClientPlayer->GetEQReverb( &roomSize, &reverb ); } return roomSize;}- (BOOL)hasVideoAttribute:(float *)curValue forKey:(int)attributeKey{ return m_pIClientPlayer ? ( m_pIClientPlayer->GetVideoAttribute( attributeKey, curValue ) ? YES : NO ) : NO;}- (BOOL)setVideoAttribute:(float)value forKey:(int)attributeKey{ return m_pIClientPlayer ? ( m_pIClientPlayer->SetVideoAttribute( attributeKey, value ) ? YES : NO ) : NO;}- (CFTypeRef)copyStatisticsFor:(NSString *)key{ CFTypeRef statisticsValue = nil; if ( m_pIClientPlayer && key ) { int valueType; UInt32 bufferLength = 0; m_pIClientPlayer->GetStatistic( [key cString], NULL, bufferLength, &valueType, &bufferLength ); if ( bufferLength > 0 ) { switch ( valueType ) { case kValueType32BitSignedInt: { SInt32 intValue; if ( m_pIClientPlayer->GetStatistic( [key cString], ( unsigned char* ) &intValue, bufferLength, &valueType, &bufferLength ) ) { statisticsValue = CFNumberCreate( kCFAllocatorDefault, kCFNumberSInt32Type, &intValue ); } } break; case kValueTypeString: { unsigned char* pValueBuffer = new unsigned char[ bufferLength ]; if ( pValueBuffer ) { if ( m_pIClientPlayer->GetStatistic( [key cString], pValueBuffer, bufferLength, &valueType, &bufferLength ) ) { statisticsValue = CFStringCreateWithCString( kCFAllocatorDefault, ( const char* ) pValueBuffer, GuessEncodingForCString( pValueBuffer ) ); } delete [] pValueBuffer; pValueBuffer = NULL; } } break; } } } return statisticsValue;}- (BOOL)addObserver:(id)observer forStatistic:(NSString *)key userInfo:(UInt32)aUserInfo{#if defined(HELIX_FEATURE_REGISTRY) && defined(HELIX_FEATURE_STATS) if ( m_pIClientPlayer ) { if ( !m_pStatisticObserver ) { m_pStatisticObserver = new CHXStatisticObserverBridge( m_pIClientPlayer ); } if ( m_pStatisticObserver ) { CHXStatisticObserverBridge* pStatisticObserverBridge = ( CHXStatisticObserverBridge* ) m_pStatisticObserver; return( pStatisticObserverBridge->AddObserver( observer, key, aUserInfo ) ? YES : NO ); } }#endif return NO;}- (void)removeObserver:(id)observer forStatistic:(NSString *)key userInfo:(UInt32)aUserInfo{#if defined(HELIX_FEATURE_REGISTRY) && defined(HELIX_FEATURE_STATS) CHXStatisticObserverBridge* pStatisticObserverBridge = ( CHXStatisticObserverBridge* ) m_pStatisticObserver; if ( pStatisticObserverBridge ) { pStatisticObserverBridge->RemoveObserver( observer, key, aUserInfo ); }#endif}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -