Esempio n. 1
0
 /// <summary>
 /// Unloads the currently loaded subtitles.
 /// </summary>
 public void UnloadSubtitles( )
 {
     this.StopSubtitles( );
     this.OnSubtitlesUnloaded?.Invoke( this, new OnSubtitlesUnloadedEventArgs( this.Subtitles ) );
     this.Subtitles = null;
 }
Esempio n. 2
0
        /// <summary>
        /// Loads a subtitles file.
        /// </summary>
        /// <param name="filePath">The path to the file.</param>
        public void LoadSubtitles( string filePath )
        {
            if ( !Player.GetComponent<MediaComponent>( ).HasMediaBeenLoaded )
                throw new Exception( "Unable to load subtitles before any media has been loaded." );

            if ( HaveSubtitlesBeenLoaded )
                this.UnloadSubtitles( );

            FileInfo file = new FileInfo( filePath );
            Subtitles = Subtitles.LoadSubtitlesFile( filePath );
            enabled = Subtitles.SubtitlesParsedSuccesfully;

            if ( Subtitles.SubtitlesParsedSuccesfully )
            {
                OnSubtitlesLoaded?.Invoke( this, new OnSubtitlesLoadedEventArgs( file ) );
                this.CheckForSubtitles( );
            }
            else
            {
                Subtitles = null;
                OnSubtitlesFailedToLoad?.Invoke( this, new OnSubtitlesFailedToLoadEventArgs( file ) );
            }
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="subs">The subtitles file.</param>
 public OnSubtitlesUnloadedEventArgs( Subtitles subs )
 {
     this.Subtitles = subs;
 }