0

MediaPlayerクラスを使用してビデオを表示しようとしています。私が見ているcodeProjectの例があります。

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            MediaTimeline timeline = 
              new MediaTimeline(new Uri("airplane.mpg", UriKind.Relative));
            timeline.RepeatBehavior = RepeatBehavior.Forever;
            MediaClock clock = timeline.CreateClock();
            MediaPlayer player = new MediaPlayer();
            player.Clock = clock;
            VideoDrawing drawing = new VideoDrawing();
            drawing.Rect = new Rect(0, 0, 300, 200);
            drawing.Player = player;
            DrawingBrush brush = new DrawingBrush(drawing);
            this.Background = brush;
        }
    }

すべてが非常にうまく機能しますが、ビデオを伸ばす方法がわかりません。ビューボックスを使用する以外に、System.Windows.Media.Stretchを使用してビデオサイズを変更する方法を知っている人はいますか?

(MediaElement、WpfMediakit、またはその他のクラスや外部ライブラリの使用を提案しないでください。この質問は、特にSystem.Windows.Media.MediaPlayerを対象としています)。

4

1 に答える 1

0

Ok I am dumb, it's actually very easy,

    drawing.Rect = new Rect(0, 0, player.NaturalVideoWidth , player.NaturalVideoHeight );
    brush.Stretch =  System.Windows.Media.Stretch.SomeStretchEnum
于 2013-02-17T08:11:08.883 に答える