problem in play/call media element sound RRS feed

  • Question

  • I create usercontrol name it Audio_Play..

    and the code in Audio_Play.xaml.cs is :

    private int _count = 8;

            // MediaElement
            private int _index = 0;

            public AudioPlayer()

                this.Loaded += new RoutedEventHandler(AudioPlayer_Loaded);

            void AudioPlayer_Loaded(object sender, RoutedEventArgs e)
                for (int i = 0; i < _count; i++)
                    var element = new MediaElement();
                    element.Volume = 0.7d;


    private void Play(string address)
                if (_index > _count - 1)
                    _index = 0;

                var element = root.Children[_index] as MediaElement;
                element.Source = new Uri(address, UriKind.Relative);


            public void PlayDrop()

            public void PlayEat()

            public void PlaySkin()

            public void PlayOver()


    then i describe it in Main.xaml

    behind Main.xaml.cs I call  PlayDrop(), PlayEat(), PlaySkin(), PlayOver(), when some action on going. But it's not working.. how to fix it.?

    and I create some action with usercontrol main.xaml, in this main.xaml.cs I create Boolean to give Enabled = false (the coding behind isnot running/Stop), and Enabled = true (the coding behind it is running)..=>> (Stop and Play the action in main.xaml). In center action I call other usercontrol and name it soal.xaml

    I stop main.xaml : main.Enabled = false, then call soal.xaml, => i doit with "if"

    then when soal.xaml visibility is collapsed, main.xaml is start again. main.enabled = true. continuing the previous action. I can't coding it..

    many thanks..

    Sunday, August 15, 2010 9:29 AM


  • Hi Dwi,

    Firstly, my test shows that there is no Enabled property with MediaElement.  We can call Stop function instead.  

    Secondly, for not working, please double check video source is correct.  As a test, you can add it to ClientBin and you can call it like this.  Play("over.wmv");


    Finally, please check whether your video is ok.  Sometimes, a video won't work even though it has a "wmv" extension.

    Best regards,


    Wednesday, August 18, 2010 4:45 AM