同时播放背景音频和视频 [英] Playing background audio and video both at same time

查看:28
本文介绍了同时播放背景音频和视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发 windows 手机应用程序.在页面中,我需要连续运行背景音频和视频(以重复模式).

I need to develop windows phone application. In that in the page i need to run background audio and video continuously (in repeat mode).

对于音频,我找到了这个例子.

现在如何在页面中添加背景视频?在页面中,我需要显示一些文本框和按钮,并在后台播放视频和音频.

Now how do i add background video in the page? In the page i need to show some textboxes and buttons and in the background video and audio both will play.

音频和视频文件都将包含在应用程序中,即不需要蒸汽.

Both audio and video file will be included in the application i.e. no steaming is needed.

推荐答案

我实际上是在几个月前为我的一项工作分配这样做的.我发现 WP7 的 Silverlight 不允许我同时播放两个 MediaElement.我所做的是创建一个Windows Phone Silverlight 和 XNA 应用程序.(现在 WP7 的 Silverlight 终于创建了一个背景音频播放器,所以如果你愿意,你可以这样做)

I actually did this for a work assignment of mine a few months back. I found out that Silverlight for WP7 did not allow me to have two MediaElements playing at the same time. What I did was create a Windows Phone Silverlight and XNA Application. (Now Silverlight for WP7 finally created a background audio player so you can do it that way if you would like)

您的应用程序可以完全在 Silverlight 中,但是您可以使用引用的 XNA(您也可以访问非常好的更新循环)

Your application can be entirely in Silverlight, but then you can use the XNA referenced (also you can have access to an update loop which is really nice)

XNA 有一个 SoundEffectSoundEffectInstance

然后加载声音只需执行以下操作:

Then to load a sound just do the following:

private SoundEffect Sound = null;
private SoundEffectInstance Instance = null;

在 Sound.cs 中播放音效

Sound = ContentManager.Load<SoundEffect>(fileName); //ContentManager will have to be instantiated from wherever you create it.
Instance = Sound.CreateInstance();
Instance.Play();

然后只需使用 Silverlight MediaElement 播放您的视频文件.

Then just use the Silverlight MediaElement to play your video file.

<MediaElement x:Name="VideoPlayer" AutoPlay="False" Width="320" Height="220"/>

代码隐藏

VideoPlayer.Source = = new Uri("fileName", UriKind.Relative);
VideoPlayer.Play();

这篇关于同时播放背景音频和视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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