Exemplo n.º 1
0
        protected void AddTrack(ITrack track, bool isExternal = false)
        {
            _tracks.Add(track);

            if (isExternal)
                _externalTracks.Add(track);
            else
                _internalTracks.Add(track);

            if (track.TrackType == TrackType.Audio)
            {
                // Update volume settings if it's an audio track
                ((AudioTrack)track).Volume = _audioVolume;
                ((AudioTrack)track).Balance = _audioBalance;

                if (!isExternal && SupportsAudioTrackSwitching())
                {
                    if (_mainAudioTrack != null)
                    {
                        // The main audio track has already been found
                        ((AudioTrack)track).Mute = true;
                    }
                    else
                    {
                        // First audio track found . now the main one
                        _mainAudioTrack = (AudioTrack)track;
                        _mainAudioTrack.Mute = false;
                    }
                }
            }
            else if (track.TrackType == TrackType.Video)
            {
                // If this track has a better time, update _nextVideoTrack
                if (_nextVideoTrack == null || ((VideoTrack)track).GetNextFrameStartTime() < _nextVideoTrack.GetNextFrameStartTime())
                    _nextVideoTrack = (VideoTrack)track;
            }

            // Keep the track paused if we're paused
            if (IsPaused)
                track.Pause(true);

            // Start the track if we're playing
            if (IsPlaying && track.TrackType == TrackType.Audio)
                ((AudioTrack)track).Start();
        }
Exemplo n.º 2
0
        public virtual void Close()
        {
            if (IsPlaying)
                Stop();

            for (int i = 0; i < _tracks.Count; i++)
            {
                // TODO: ? _tracks[i].Dispose();
                _tracks[i] = null;
            }

            _tracks.Clear();
            _internalTracks.Clear();
            _externalTracks.Clear();
            _dirtyPalette = false;
            _palette = null;
            _startTime = 0;
            _audioVolume = Mixer.MaxChannelVolume;
            _audioBalance = 0;
            _pauseLevel = 0;
            _needsUpdate = false;
            _lastTimeChange = new Timestamp(0);
            _endTime = new Timestamp(0);
            _endTimeSet = false;
            _nextVideoTrack = null;
            _mainAudioTrack = null;
        }