LoginSignup
1
2

More than 5 years have passed since last update.

iOS11 フルスクリーン動画再生中にシングルタップでスキップできない問題の対処方法

Posted at

[IOS] FULLSCREENMOVIECONTROLMODE.CANCELONINPUT DOES NOT WORK ON IOS11
https://issuetracker.unity3d.com/issues/ios-fullscreenmoviecontrolmode-dot-canceloninput-does-not-work-on-ios11
Unity 2017.3 で直る模様。

PostProcessBuild で FullScreenVideoPlayer.mm ファイルに追記するサンプル。
Editor フォルダ配下に配置してビルド。

FullScreenVideoPlayerForIOS11.cs
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;


namespace BuildScripts
{
    public class FullScreenVideoPlayerForIOS11
    {
        private const string TEXT = @"
@interface UIWindow (VideoPlay)
@end


@implementation UIWindow(VideoPlay)
- (void)touchesBegan:(NSSet<UITouch*>*)touches withEvent: (UIEvent*)event
{
[super touchesBegan: touches withEvent: event];


NSString *version = [UIDevice currentDevice].systemVersion;
if(version.doubleValue >= 11 && UnityIsFullScreenPlaying())
{
UnityStopFullScreenVideoIfPlaying();
}
}
@end";

        [PostProcessBuild(100)]
        public static void OnPostProcessBuild(BuildTarget target, string path)
        {
            if (target == BuildTarget.iOS)
            {
                var filePath = Path.Combine(path, "Classes/Unity/FullScreenVideoPlayer.mm");

                if (!File.Exists(filePath))
                {
                    throw new FileNotFoundException("Unity で生成されるはずのファイルが存在しません。", filePath);
                }

                using (var streamWriter = new StreamWriter(filePath, true))
                {
                    streamWriter.WriteLine();
                    streamWriter.Write(TEXT);
                }
            }
        }
    }
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2