Added sound support for vgui_movie_display

This commit is contained in:
Alivebyte 2021-04-25 15:48:29 +03:00
parent 264ee2b04f
commit ae4e26f03b
3 changed files with 16 additions and 5 deletions

View File

@ -13,6 +13,7 @@
IMPLEMENT_CLIENTCLASS_DT( C_MovieDisplay, DT_MovieDisplay, CMovieDisplay )
RecvPropBool( RECVINFO( m_bEnabled ) ),
RecvPropBool( RECVINFO( m_bLooping ) ),
RecvPropBool( RECVINFO( m_bMuted ) ),
RecvPropString( RECVINFO( m_szMovieFilename ) ),
RecvPropString( RECVINFO( m_szGroupName ) ),
END_RECV_TABLE()

View File

@ -20,6 +20,7 @@ public:
bool IsEnabled( void ) const { return m_bEnabled; }
bool IsLooping( void ) const { return m_bLooping; }
bool IsMuted(void) const { return m_bMuted; }
const char *GetMovieFilename( void ) const { return m_szMovieFilename; }
const char *GetGroupName( void ) const { return m_szGroupName; }
@ -27,6 +28,7 @@ public:
private:
bool m_bEnabled;
bool m_bLooping;
bool m_bMuted;
char m_szMovieFilename[128];
char m_szGroupName[128];
};

View File

@ -81,7 +81,7 @@ private:
bool m_bBlackBackground;
bool m_bSlaved;
bool m_bInitialized;
bool m_bStopAllSounds;
bool m_bLastActiveState; // HACK: I'd rather get a real callback...
// VGUI specifics
@ -110,10 +110,10 @@ CMovieDisplayScreen::CMovieDisplayScreen( vgui::Panel *parent, const char *panel
m_bBlackBackground = true;
m_bSlaved = false;
m_bInitialized = false;
m_bStopAllSounds = true;
// Add ourselves to the global list of movie displays
g_MovieDisplays.AddToTail( this );
//m_VideoMaterial->SetMuted(true);
m_bLastActiveState = IsActive();
}
@ -295,6 +295,11 @@ void CMovieDisplayScreen::UpdateMovie( void )
// OnVideoOver();
// StopPlayback();
}
if (!m_hScreenEntity->IsMuted())
{
m_VideoMaterial->SetMuted(false);
}
}
}
@ -376,14 +381,17 @@ bool CMovieDisplayScreen::BeginPlayback( const char *pFilename )
if ( m_VideoMaterial == NULL )
return false;
m_VideoMaterial->SetMuted(true); // FIXME: Allow?
if ( m_hScreenEntity->IsLooping() )
{
m_VideoMaterial->SetLooping( true );
}
if ( m_VideoMaterial->HasAudio() )
if ( m_VideoMaterial->HasAudio() && m_bStopAllSounds)
{
// We want to be the sole audio source
enginesound->NotifyBeginMoviePlayback();