I am trying to match the orientation of the video with the orientation of the phone, but I am having problems with this solution. My xaml page is set to PortraitOrLandscape and I would like the video to be right-side up, regardless of the orientation of the phone. Before adding orientation changes, if the instructions are in the onOrentationChanged event, the following situation occurs
Phone: Landscape on the left, Video: right up
Phone: portrait, video rotated -90 clockwise
Phone: Landscape on the right, Movie rotated -180 clockwise
Xaml
<Rectangle x:Name="videoRectangle" Margin="0,0,0,0"> <Rectangle.Fill> <VideoBrush x:Name="viewfinderBrush" AlignmentX="Left" AlignmentY="Top" Stretch="UniformToFill"> <VideoBrush.RelativeTransform> <CompositeTransform x:Name="viewfinderTransform" CenterX="0.5" CenterY="0.5"/> </VideoBrush.RelativeTransform> </VideoBrush> </Rectangle.Fill> </Rectangle>
XAML.CS
protected override void OnOrientationChanged(OrientationChangedEventArgs e) { base.OnOrientationChanged(e); if (e.Orientation == PageOrientation.LandscapeLeft) { //do nothing //The videobrush orientation is currently right side up } if (e.Orientation == PageOrientation.Portrait) { //the videobrush is currently rotated 90 degrees counter clockwise this.viewfinderTransform.Rotation = this.camera.Orientation + 90.0; } if (e.Orientation == PageOrientation.LandscapeRight) { //the videobrush is currently rotated 180 degrees counter clockwise this.viewfinderTransform.Rotation = this.camera.Orientation + 180; } }
And after adding if statements, the video orientation becomes even crazier. What am I doing wrong? I just would like the right side of the video to face up regardless of the orientation of the phone.
source share