0

アプリで動画を再生したい。私は周りを見ていますが、何も助けにはなりませんでした。携帯電話の音楽を聴きたいかどうかユーザーに尋ねます。[OK] をクリックすると音楽が再生され続け、そうでない場合は音楽が停止します。それは今から大丈夫です。今、私の問題は次のとおりです。幅と高さなどのポップアップのように使用するグリッドを作成します。このポップアップが表示されると、音楽が停止します。これが、マーケットプレイスでアプリを認定できない理由です。ここに小さなコードがあります:私は理解しやすいと信じています...助けてください!

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 を送信して、動画の 1 つを選択します。動画を Build Action Content に設定します。

何をすべきか?それともこれとは違うものですか?私はビデオを再生したい..ビデオには音楽がありません..または効果音..

4

1 に答える 1

0

私はそれをテストし、それは動作します。イベントを呼び出すときにビデオをポップアップしたい。そのため、グリッドをファイル 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.cs で

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);

            }

        }
于 2012-04-17T16:58:05.880 に答える