/// <summary>
        /// Meldet die bevorzugte Tonspur.
        /// </summary>
        /// <returns>Der Name der bevorzugten Tonspur.</returns>
        public string GetPreferredAudio()
        {
            // Make sure that list is filled
            FillAudioList();

            // Item to find
            AudioItem audio = GetPreferredAudioFromList();

            // Use preferred track
            if (null == audio)
            {
                if (!string.IsNullOrEmpty(m_PrimaryTrack))
                {
                    if (!m_Tracks.TryGetValue(m_PrimaryTrack, out audio))
                    {
                        audio = null;
                    }
                }
            }

            // Use first
            if ((null == audio) && (selAudio.Items.Count > 0))
            {
                audio = (AudioItem)selAudio.Items[0];
            }

            // Report
            return((null == audio) ? null : audio.AudioName);
        }
        private AudioItem GetPreferredAudioFromList()
        {
            // Make sure that list is filled
            FillAudioList();

            // Check default
            if (string.IsNullOrEmpty(Configuration.PreferredLanguage))
            {
                return(null);
            }

            // Check for exact match
            AudioItem audio;

            if (m_Tracks.TryGetValue(Configuration.PreferredLanguage, out audio))
            {
                if (null != audio)
                {
                    return(audio);
                }
            }

            // Find
            AudioItem bestMP2 = null, anyMP2 = null;

            ScanTracks(false, ref anyMP2, ref bestMP2);

            // Check modes
            if (Configuration.PreferAC3)
            {
                // Find
                AudioItem bestAC3 = null, anyAC3 = null;
                ScanTracks(true, ref anyAC3, ref bestAC3);

                // Check for AC3 hit
                if (null != bestAC3)
                {
                    return(bestAC3);
                }

                // At least prefer AC3
                if (null != anyAC3)
                {
                    return(anyAC3);
                }
            }

            // Check for MP2 hit
            if (null != bestMP2)
            {
                return(bestMP2);
            }

            // Use any
            return(anyMP2);
        }
예제 #3
0
        public int CompareTo(object obj)
        {
            // Change type
            AudioItem other = obj as AudioItem;

            // Not comparable
            if (null == other)
            {
                return(-1);
            }

            // By name
            return(ToString().CompareTo(other.ToString()));
        }
        private void selAudio_SelectionChangeCommitted(object sender, EventArgs e)
        {
            // Get the item
            AudioItem audio = CurrentAudio;

            // None
            if (null == audio)
            {
                return;
            }

            // Forward
            OnAudioSelected(audio.AudioName);
        }
        /// <summary>
        /// Meldet eine Tonspur an.
        /// </summary>
        /// <param name="audioName">Der Name der Tonspur.</param>
        /// <param name="primary">Gesetzt, wenn es sich um die primäre Tonspur handelt.</param>
        public void AddAudio(string audioName, bool primary)
        {
            // Create and remember
            m_Tracks[audioName] = new AudioItem(audioName);

            // Remember primary
            if (primary)
            {
                m_PrimaryTrack = audioName;
            }

            // Mark as changed
            m_AudioLoaded = false;
        }
        private void ScanTracks(bool ac3, ref AudioItem any, ref AudioItem hit)
        {
            // Test for AC3
            string testAC3 = " (AC3) [";

            // Create the key
            string key = Configuration.PreferredLanguage + (ac3 ? testAC3 : " [");

            // Already failed
            bool failed = false;

            // Test all
            foreach (KeyValuePair <string, AudioItem> test in m_Tracks)
            {
                // Check mode
                bool isAC3 = (test.Key.IndexOf(testAC3) >= 0);

                // Skip
                if (isAC3 != ac3)
                {
                    continue;
                }

                // Set any
                if ((null == any) || (test.Value.Index < any.Index))
                {
                    any = test.Value;
                }

                // Match
                if (!test.Key.StartsWith(key))
                {
                    continue;
                }

                // Test
                failed = (null != hit);

                // Remember
                hit = test.Value;
            }

            // Wipe out
            if (failed)
            {
                hit = null;
            }
        }
        /// <summary>
        /// Wählt eine Tonspur aus.
        /// </summary>
        /// <param name="audioName">Der Name der Tonspur.</param>
        /// <returns>Gesetzt, wenn die Auswahl erfolgreich war.</returns>
        public bool SelectAudio(string audioName)
        {
            // Make sure that list is filled
            FillAudioList();

            // Item to find
            AudioItem audio = null;

            // Default
            if (string.IsNullOrEmpty(audioName))
            {
                audio = GetPreferredAudioFromList();
            }

            // Try lookup
            if (null == audio)
            {
                // Use preferred track
                if (string.IsNullOrEmpty(audioName))
                {
                    audioName = m_PrimaryTrack;
                }

                // Default
                if (!string.IsNullOrEmpty(audioName))
                {
                    if (!m_Tracks.TryGetValue(audioName, out audio))
                    {
                        audio = null;
                    }
                }
            }

            // Use first
            if ((null == audio) && (selAudio.Items.Count > 0))
            {
                audio = (AudioItem)selAudio.Items[0];
            }

            // Use it
            selAudio.SelectedItem = audio;

            // Report
            selAudio_SelectionChangeCommitted(selAudio, EventArgs.Empty);

            // Report
            return(null != audio);
        }
        /// <summary>
        /// Initialisiert die Liste der Tonspuren.
        /// </summary>
        public void FillAudioList()
        {
            // Already did it
            if (m_AudioLoaded)
            {
                return;
            }

            // Once only
            m_AudioLoaded = true;

            // Create temporary list
            List <AudioItem> tracks = new List <AudioItem>(m_Tracks.Values);

            // Reset index
            foreach (AudioItem audio in tracks)
            {
                audio.Index = '\0';
            }

            // Sort
            tracks.Sort();

            // Add shortcut information
            if (m_Embedded || ShortCutsEnabled)
            {
                for (int i = tracks.Count; i-- > 0;)
                {
                    // Load
                    AudioItem audio = tracks[i];

                    // Set index
                    audio.Index = (char)('A' + i);
                }
            }

            // Add to list
            selAudio.Items.Clear();
            selAudio.Items.AddRange(tracks.ToArray());

            // Enable
            selAudio.Enabled = (selAudio.Items.Count > 1);
        }
예제 #9
0
        private void ScanTracks( bool ac3, ref AudioItem any, ref AudioItem hit )
        {
            // Test for AC3
            string testAC3 = " (AC3) [";

            // Create the key
            string key = Configuration.PreferredLanguage + (ac3 ? testAC3 : " [");

            // Already failed
            bool failed = false;

            // Test all
            foreach (KeyValuePair<string, AudioItem> test in m_Tracks)
            {
                // Check mode
                bool isAC3 = (test.Key.IndexOf( testAC3 ) >= 0);

                // Skip
                if (isAC3 != ac3) continue;

                // Set any
                if ((null == any) || (test.Value.Index < any.Index)) any = test.Value;

                // Match
                if (!test.Key.StartsWith( key )) continue;

                // Test
                failed = (null != hit);

                // Remember
                hit = test.Value;
            }

            // Wipe out
            if (failed) hit = null;
        }
예제 #10
0
        /// <summary>
        /// Meldet eine Tonspur an.
        /// </summary>
        /// <param name="audioName">Der Name der Tonspur.</param>
        /// <param name="primary">Gesetzt, wenn es sich um die primäre Tonspur handelt.</param>
        public void AddAudio( string audioName, bool primary )
        {
            // Create and remember
            m_Tracks[audioName] = new AudioItem( audioName );

            // Remember primary
            if (primary) m_PrimaryTrack = audioName;

            // Mark as changed
            m_AudioLoaded = false;
        }