更改MediaElement中的源(SILVERLIGHT) [英] Change Source in MediaElement (SILVERLIGHT)

查看:100
本文介绍了更改MediaElement中的源(SILVERLIGHT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将MediaElent上的歌曲从track1.mp3更改为track2.mp3.这是代码:

I would like to change song on my MediaElent from track1.mp3 to track2.mp3. And here is the code:

MyMediaElement.Stop();
Uri u = new Uri("track2.mp3", UriKind.Relative);
MyMediaElement.Source=u;
MyMediaElement.Play();

MediaElement更改了源,但不会启动.此代码可能有什么问题?

The MediaElement change the source but just won't start. What could possibly be wrong with this code?

推荐答案

尝试在源更改后立即将MyMediaElement.AutoPlay设置为true.您还可以使用MediaElement.SetSource()方法进行调查,该方法采用流而不是uri.

Try setting MyMediaElement.AutoPlay to true, as soon as the source changes it should play. You could also investigate using the MediaElement.SetSource() method which takes a stream rather than a uri.

这篇关于更改MediaElement中的源(SILVERLIGHT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆