Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

For Audio, i found this example.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
291 views
Welcome To Ask or Share your Answers For Others

1 Answer

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)

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 has a SoundEffect and SoundEffectInstance class

Then to load a sound just do the following:

Globals in you wrapper class Sound.cs

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

Playing a Sound Effect in Sound.cs

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

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

XAML

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

CodeBehind

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...