在Windows Phone 7的设置源MediaElement的?

编程入门 行业动态 更新时间:2024-10-28 02:20:15
本文介绍了在Windows Phone 7的设置源MediaElement的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想设置在C#中媒体元素的来源。这是我在做什么。

I'm trying to set the source of a media element in C#. This is what I'm doing

XAML部分

<MediaElement x:Name="Sound" AutoPlay="False" /> <Button Content="Shout!" Height="123" Name="button2" Width="123" Click="shout_Click" />

C#部分

private void shout_Click(object sender, RoutedEventArgs e) { this.Sound.Source = new Uri("Sounds/fusrodah.wma", UriKind.Relative); this.Sound.Play(); }

以上不起作用。但是,如果我在XAML手动设置路径它的工作原理。我怎样才能设置在C#的MediaElement 的来源?

推荐答案

你得到一个错误,或者它只是不玩?尝试添加一个斜杠,Dovahkiin:

Do you get an error, or does it just not play? Try adding a forward slash, Dovahkiin:

this.Sound.Source = new Uri("/Sounds/fusrodah.wma", UriKind.Relative);

更多推荐

在Windows Phone 7的设置源MediaElement的?

本文发布于:2023-07-11 11:54:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093959.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Windows   Phone   MediaElement

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!