Is it possible to disable zoom when a video is played on iOS?

Kim Strasser 1,036 Reputation points
2024-07-30T19:58:30.3266667+00:00

I found out that I can zoom in and zoom out when I make a two finger gesture on my iOS device when a video is played. Is it possible to disable the zoom so that nothing happens when the user tries to zoom?

var directory = Path.GetDirectoryName("Testvideo1");
var playURL = NSBundle.MainBundle.GetUrlForResource("Testvideo1", "mp4", directory);
var player = new AVPlayer(playURL);
var PlayerViewController = new AVPlayerViewController();
PlayerViewController.Player = player;
PlayerViewController.EntersFullScreenWhenPlaybackBegins = true;//full screen
PlayerViewController.ShowsPlaybackControls = false;
var gameController = this.Services.GetService(typeof(UIViewController)) as UIViewController;
gameController.PresentViewController(PlayerViewController, true, () =>
{
    player.Play();
});
NSNotificationCenter.DefaultCenter.AddObserver(new NSString("AVPlayerItemDidPlayToEndTimeNotification"), (notification) =>
{
    PlayerViewController.DismissViewController(true, null);// add observer to catch the ending event
}, PlayerViewController.Player.CurrentItem);
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,202 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,607 questions
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points Microsoft Vendor
    2024-07-31T08:57:45.09+00:00

    Hello,

    Please set PlayerViewController.View.UserInteractionEnabled = false; When set to NO, touch, press, keyboard, and focus events intended for the view are ignored and removed from the event queue, see userInteractionEnabled | Apple Developer Documentation

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.