question

karthikvr-7960 avatar image
0 Votes"
karthikvr-7960 asked ·

Zoom functionality in MediaPlayerElement: not getting manipulation events for scale gestures

I want to add zoom functionality for media player element(UWP C#) . I placed MediaPlayerElement inside a scroll viewer and zoom functionality is working. But inbuilt media transport transport controls is also getting zoomed and scrolled. To avoid this I tried implementing zoom through manipulation events as suggested in media player element doumentation https://docs.microsoft.com/en-gb/windows/uwp/audio-video-camera/play-audio-and-video-with-mediaplayer#pinch-and-zoom-video I am not getting manipulation events for scale gestures((I tried mouse scroll, pinch gesture and stretch gesture in touch pad). But I am getting maniplation delta events for translate gestures. Am I missing something. The code I tried is exactly same as said in the above link. _mediaPlayerElement.ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY; _mediaPlayerElement.ManipulationDelta += _mediaPlayerElement_ManipulationDelta;

uwpuwp-xaml
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could share us with code sample that you have written ?

0 Votes 0 · ·

Thanks. I have shared my sample code : https://1drv.ms/u/s!AizIJTHyJpeMbBZybyJPe-Xrta0?e=Pnl0KX

0 Votes 0 · ·

1 Answer

NicoZhu-MSFT avatar image
0 Votes"
NicoZhu-MSFT answered ·

Please check this paragraph from document

allows you to specify the source rectangle within video content that should be rendered, effectively allowing you to zoom into video. The rectangle you specify is relative to a normalized rectangle (0,0,1,1) where 0,0 is the upper left hand of the frame and 1,1 specifies the full width and height of the frame. So, for example, to set the zoom rectangle so that the top-right quadrant of the video is rendered, you would specify the rectangle (.5,0,.5,.5). It is important that you check your values to make sure that your source rectangle is within the (0,0,1,1) normalized rectangle. Attempting to set a value outside of this range will cause an exception to be thrown.

So please set the Rect smaller than 1 in the double tap event.

 private void _mediaPlayerElement_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
 {
     _sourceRect = new Rect(0, 0, 0.5, 0.5);
     _mediaPlayerElement.MediaPlayer.PlaybackSession.NormalizedSourceRect = _sourceRect;
 }



· 10 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, Double tap is to reset zoom : T"he DoubleTapped event will be used to reset the zoom to the full frame." My issues is I am not getting a call to _mediaPlayerElement_ManipulationDelta when I do pinch or stretch.

0 Votes 0 · ·

I tested with simulator when i use touch model it could works well(hold left click scroll wheel up down), please share which device you have tested

0 Votes 0 · ·

I am running on my local machine . HP EliteBook 840 g5 . I am using the inbuilt touch pad

0 Votes 0 · ·

I just tested with Surface book, it works with touch model.

0 Votes 0 · ·

Thanks. I tested using a simulator.Touch screen works. But using touch pad it doesn't work. So does this mean I won't get a manipulation delta events when doing scale gestures using a touch pad ?

0 Votes 0 · ·
Show more comments