Windows phone 7 如何在wp7 silverlight中播放视频(wmv文件)
我想在我的应用程序中播放视频。我四处看看,但什么都帮不了我。我问用户是否想要听他的手机音乐。如果单击“确定”,音乐将继续播放,否则音乐将停止。从现在开始没关系。现在,我的问题是:我创建一个网格来使用它,就像弹出窗口一样,有宽度和高度等等。。当弹出窗口出现时,音乐停止。这就是为什么我不能在市场上认证我的应用程序。 这里有一个小代码:我相信很容易理解。。。请帮忙Windows phone 7 如何在wp7 silverlight中播放视频(wmv文件),windows-phone-7,video,Windows Phone 7,Video,我想在我的应用程序中播放视频。我四处看看,但什么都帮不了我。我问用户是否想要听他的手机音乐。如果单击“确定”,音乐将继续播放,否则音乐将停止。从现在开始没关系。现在,我的问题是:我创建一个网格来使用它,就像弹出窗口一样,有宽度和高度等等。。当弹出窗口出现时,音乐停止。这就是为什么我不能在市场上认证我的应用程序。 这里有一个小代码:我相信很容易理解。。。请帮忙 public void new_grid(int v) { Grid gr = new Grid(
public void new_grid(int v)
{
Grid gr = new Grid();
gr.Background = new SolidColorBrush(Colors.Cyan);
gr.Opacity = 1.0;
gr.Width = 400;
gr.Height = 600;
// Create a white border.
Border border = new Border();
border.BorderBrush = new SolidColorBrush(Colors.White);
border.BorderThickness = new Thickness(7.0);
MediaElement video_ship = new MediaElement();
//video_ship.AutoPlay = false;
video_ship.Width = 400;
video_ship.Height = 600;
video_ship.VerticalAlignment = VerticalAlignment.Top;
video_ship.HorizontalAlignment = HorizontalAlignment.Left;
if (v == 1)
{
video_ship.Source = new Uri("videos/Lost_Ship.wmv", UriKind.RelativeOrAbsolute);
//video_ship.Play();
gr.Children.Add(video_ship);
}
else if (v == 2)
{
//video_ship.Source = "videos/Lost_Ship.wmv";
video_ship.Source = new Uri("videos/you_are_on_fire.wmv", UriKind.RelativeOrAbsolute);
//video_ship.Name = "fire";
//video_ship.Play();
gr.Children.Add(video_ship);
}
else if (v == 3)
{
//video_ship.SourceName = "videos/Lost_Ship.wmv";
video_ship.Source = new Uri("videos/EscapeShip.wmv", UriKind.RelativeOrAbsolute);
//video_ship.Name = "escape";
//video_ship.Play();
gr.Children.Add(video_ship);
}
我发送一个变量v来选择我的一个视频。我将视频设置为生成动作内容
你知道怎么做吗?或者其他不同的东西?
我只想播放视频..视频没有音乐..或音效..我测试了它,它工作正常。您想在调用事件时弹出视频。所以,您应该将网格放在文件xaml代码中,它是隐藏的。 这是我的测试 关于xaml
<Grid x:Name="LayoutRoot" Background="Transparent">
<Image Source="BackgroundMain3.jpg" Stretch="UniformToFill"/>
<Grid Height="400" Width="600" x:Name="playvideo" Visibility="Collapsed">
<MediaElement x:Name="element"/>
</Grid>
<Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="129,684,0,0" Name="button1" VerticalAlignment="Top" Width="160" Click="button1_Click" />
</Grid>
我没有测试你的建议,但我认为一直浏览xaml页面不是很好。。。但我认为:当播放音乐时,我不会显示带有视频的弹出窗口,否则我会…你认为这是更好的解决方案吗?可能是工作吗?
private void button1_Click(object sender, RoutedEventArgs e)
{
poupup(3);
playvideo.Visibility = Visibility.Visible;
playvideo.Opacity = 0.8;
element.MediaOpened += new RoutedEventHandler(element_MediaOpened);
}
void element_MediaOpened(object sender, RoutedEventArgs e)
{
element.Play();
}
public void poupup(int v)
{
if (v == 1)
{
element.Source = new Uri("videos/Lost_Ship.wmv", UriKind.RelativeOrAbsolute);
}
else if (v == 2)
{
element.Source = new Uri("videos/you_are_on_fire.wmv", UriKind.RelativeOrAbsolute);
}
else if (v == 3)
{
element.Source = new Uri("YouTube.mp4", UriKind.RelativeOrAbsolute);
}
}