Ejemplo n.º 1
0
 private void PopulateAudioTracks(
     MediaElement media, ComboBox audioSelection)
 {
     if (media.AudioStreamCount > 0)
     {
         for (int index = 0; index < media.AudioStreamCount; index++)
         {
             ComboBoxItem track = new ComboBoxItem();
             track.Content = media.GetAudioStreamLanguage(index);
             audioSelection.Items.Add(track);
         }
     }
 }
        // <SnippetPlaybackAudioTracks>
        /// <summary>
        /// Attemps to set the audio track of a video to a specific language
        /// </summary>
        /// <param name="lcid">The id of the language. For example, "en" or "ja"</param>
        /// <returns>true if the track was set; otherwise, false.</returns>
        private bool SetAudioLanguage(string lcid, MediaElement media)
        {
            bool wasLanguageSet = false;

            for (int index = 0; index < media.AudioStreamCount; index++)
            {
                if (media.GetAudioStreamLanguage(index) == lcid)
                {
                    media.AudioStreamIndex = index;
                    wasLanguageSet         = true;
                }
            }

            return(wasLanguageSet);
        }
Ejemplo n.º 3
0
        public static List <string> SetAudioLanguage(MediaElement media)
        {
            //bool wasLanguageSet = false;
            List <string> audioLanguage_list = new List <string>();

            for (int index = 0; index < media.AudioStreamCount; index++)
            {
                //if (media.GetAudioStreamLanguage(index) == "en")
                //{
                //media.AudioStreamIndex = index;
                //wasLanguageSet = true;
                //}
                string str = media.GetAudioStreamLanguage(index).ToString();
                if (str == "")
                {
                    str = "默认";
                }
                audioLanguage_list.Add(str);
            }

            //return wasLanguageSet;
            return(audioLanguage_list);
        }