adding media element in windows phone 7?

前端 未结 2 1683
再見小時候
再見小時候 2020-12-04 04:08

I want to play an audio of an image whenever click on it .If we click on another image that sound will play in that way we want write the logic.

相关标签:
2条回答
  • 2020-12-04 04:33

    If you're binding to an object that has the image uri and audio clip uri:

    <Image Source="{Binding ImagePath}" Tag="{Binding AudioPath} MouseLeftButtonDown="img_MouseLeftButtonDown" />
    

    then in the event handler

        void img_MouseLeftButtonDown(object sender,MouseButtonEventArgs e)
        {
    Image img = sender as Image;
    if (img != null)
    mePlayer.Source = img.Tag as Uri;
        }
    
    0 讨论(0)
  • 2020-12-04 04:33

    i dont recommend mediaElement for more than one audio item ..it has weird effects ...use something like:

    Stream stream = TitleContainer.OpenStream(@"Audio/buzzer.wav");

            SoundEffect effect = SoundEffect.FromStream(stream);
            FrameworkDispatcher.Update();
            effect.Play();
    

    using the xna framework ....

    0 讨论(0)
提交回复
热议问题