2009-03-04 11 views
1

これは私をかなり夢中にしています。私はそれが再生された後に自動逆行するWMVファイルを取得しようとしているが、それは動作しません。私はストーリーボードのオートリバーブをtrueに設定しようとしましたが、これはエラーをスローします。MediaElement Storyboardを自動逆転させることができません

"CanSlipの時計は、親または祖先にAutoReverse、AccelerationRatio、DecelerationRatioを持つことはできません。

アニメーションではなく動画を使用しているためですか?どうすれば同じことができますか? ビデオが再生され、一時停止して再開しています。しかし、それが終了した後、それはちょうど停止します。

私は3つのストーリーボードをまとめました.1つはビデオそのものです。そして2つの場所には、ビデオの再生と一時停止のように白い矩形が消えるアニメーションがあります。

public partial class Window1 
{ 

    public Storyboard RectangleFadeA; 
    public Storyboard RectangleFadeBackA; 
    public Storyboard VideoA; 

    bool isPlaying; 
    bool isPaused; 

    public Window1() 
    { 
     this.InitializeComponent(); 

     // Insert code required on object creation below this point. 
     RectangleFadeA = (Storyboard)TryFindResource("RectangleFadeA"); 
     RectangleFadeBackA = (Storyboard)TryFindResource("RectangleFadeBackA"); 
     VideoA = (Storyboard)TryFindResource("GTTV_promo_wmv");   

     isPlaying = false; 
     isPaused = false; 
    } 


    private void rectangle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
    { 
     if (!isPlaying) 
     { 
      if (!isPaused) 
      { 

       if (RectangleFadeA != null) 
        RectangleFadeA.Begin(this, true); 

       if (VideoA != null) 
        VideoA.Begin(this, true); 

       isPlaying = true; 
       return; 

      } 
      if (isPaused) 
      { 
       if (RectangleFadeA != null) 
        RectangleFadeA.Begin(this, true); 
       if (VideoA != null) 
        VideoA.Resume(this); 
       isPaused = false; 
       isPlaying = true; 
       return; 
      } 
     } 

     if (isPlaying) 
     { 
      if (RectangleFadeBackA != null) 
       RectangleFadeBackA.Begin(this, true); 
      VideoA.Pause(this); 
      isPlaying = false; 
      isPaused = true; 
      return; 

     } 



    } 

} 

答えて

1

ちょうど多くのコードなしで解決策を見つけた:

のコードは次のようになります。 まずは、ビデオ(MediaTimeLine)をrepeatbehaviour = foreverに設定しました。 それから私は

"MediaEnded" でのMediaElementにイベントハンドラを追加し、C#のコードは次のようになります。

public partial class Window1 
{ 
    public Storyboard RectangleFadeA; 
    public Storyboard RectangleFadeBackA; 

    public Storyboard VideoA; 

    bool isPlaying; 
    bool isPaused; 


    public Window1() 
    { 
     this.InitializeComponent(); 

     // Insert code required on object creation below this point. 
     RectangleFadeA = (Storyboard)TryFindResource("RectangleFadeA"); 
     RectangleFadeBackA = (Storyboard)TryFindResource("RectangleFadeBackA"); 
     VideoA = (Storyboard)TryFindResource("GTTV_promo_wmv"); 
     isPlaying = false; 
     isPaused = false; 

    } 

    private void rectangle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
    { 
     if (!isPlaying) 
     { 
      if (!isPaused) 
      { 

       if (RectangleFadeA != null) 
        RectangleFadeA.Begin(this, true); 

       if (VideoA != null) 
        VideoA.Begin(this, true); 

       isPlaying = true; 
       return; 

      } 
      if (isPaused) 
      { 
       if (RectangleFadeA != null) 
        RectangleFadeA.Begin(this, true); 
       if (VideoA != null) 
        VideoA.Resume(this); 
       isPaused = false; 
       isPlaying = true; 
       return; 
      } 

     } 

     if (isPlaying) 
     { 
      if (RectangleFadeBackA != null) 
       RectangleFadeBackA.Begin(this, true); 
      VideoA.Pause(this); 
      isPlaying = false; 
      isPaused = true; 
      return; 

     } 

    } 

    private void ButtonWebcam_Click(object sender, RoutedEventArgs e) 
    { 
     OpeningWindows.Window2 Window2 = new OpeningWindows.Window2(); 
     Window2.ShowDialog(); 
    } 

    private void GTTV_promo_wmv_MediaEnded(object sender, RoutedEventArgs e) 
    { 
     RectangleFadeBackA.Begin(this, true); 
     VideoA.Pause(this); 
     isPaused = true; 
     isPlaying = false; 
     return; 

    } 
} 
:だから

private void GTTV_promo_wmv_MediaEnded(object sender, RoutedEventArgs e) 
    { 
     RectangleFadeBackA.Begin(this, true); 
     VideoA.Pause(this); 
     isPaused = true; 
     isPlaying = false; 
     return; 

    } 

、完全なC#のコードは、これまでのところ、このようになります。

関連する問題