public static MediaPlayer.OptionsApple.Flags SetResumePlaybackAfterAudioSessionRouteChange(this MediaPlayer.OptionsApple.Flags flags, bool b)
 {
     if (flags.ResumePlaybackAfterAudioSessionRouteChange() ^ b)
     {
         flags = b ? flags | MediaPlayer.OptionsApple.Flags.ResumeMediaPlaybackAfterAudioSessionRouteChange
                                   : flags & ~MediaPlayer.OptionsApple.Flags.ResumeMediaPlaybackAfterAudioSessionRouteChange;
     }
     return(flags);
 }
        private void OnInspectorGUI_Override_Apple(Platform platform)
        {
            GUILayout.Space(8f);

            string optionsVarName = MediaPlayer.GetPlatformOptionsVariable(platform);

            EditorGUILayout.BeginVertical(GUI.skin.box);

            DisplayPlatformOption(optionsVarName, _optionTextureFormat);

            SerializedProperty flagsProp = serializedObject.FindProperty(optionsVarName + "._flags");

            MediaPlayer.OptionsApple.Flags flags = flagsProp != null ? (MediaPlayer.OptionsApple.Flags)flagsProp.intValue : 0;

            // Texture flags
            if (flagsProp != null)
            {
                bool generateMipmaps = flags.GenerateMipmaps();
                generateMipmaps = EditorGUILayout.Toggle(new GUIContent("Generate Mipmaps"), generateMipmaps);
                flags           = flags.SetGenerateMipMaps(generateMipmaps);
            }

            // Audio
            DisplayPlatformOption(optionsVarName, _optionAudioMode);

            // Platform specific flags
            if (flagsProp != null)
            {
                if (platform == Platform.MacOSX || platform == Platform.iOS)
                {
                    bool b = flags.AllowExternalPlayback();
                    b     = EditorGUILayout.Toggle(new GUIContent("Allow External Playback", "Enables support for playback on external devices via AirPlay."), b);
                    flags = flags.SetAllowExternalPlayback(b);
                }

                if (platform == Platform.iOS)
                {
                    bool b = flags.ResumePlaybackAfterAudioSessionRouteChange();
                    b     = EditorGUILayout.Toggle(new GUIContent("Resume playback after audio route change", "The default behaviour is for playback to pause when the audio route changes, for instance when disconnecting headphones."), b);
                    flags = flags.SetResumePlaybackAfterAudioSessionRouteChange(b);
                }

                bool playWithoutBuffering = flags.PlayWithoutBuffering();
                playWithoutBuffering = EditorGUILayout.Toggle(new GUIContent("Play without buffering"), playWithoutBuffering);
                flags = flags.SetPlayWithoutBuffering(playWithoutBuffering);

                bool useSinglePlayerItem = flags.UseSinglePlayerItem();
                useSinglePlayerItem = EditorGUILayout.Toggle(new GUIContent("Use single player item", "Restricts the media player to using only one player item. This can help reduce network usage for remote videos but will cause a stall when looping."), useSinglePlayerItem);
                flags = flags.SetUseSinglePlayerItem(useSinglePlayerItem);
            }

            SerializedProperty maximumPlaybackRateProp = serializedObject.FindProperty(optionsVarName + ".maximumPlaybackRate");

            if (maximumPlaybackRateProp != null)
            {
                EditorGUILayout.Slider(maximumPlaybackRateProp, 2.0f, 10.0f, new GUIContent("Max Playback Rate", "Increase the maximum playback rate before which playback switches to key-frames only."));
            }

            GUILayout.Space(8f);

            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Network", EditorStyles.boldLabel);

            SerializedProperty preferredMaximumResolutionProp = DisplayPlatformOption(optionsVarName, _optionPreferredMaximumResolution);

            if ((MediaPlayer.OptionsApple.Resolution)preferredMaximumResolutionProp.intValue == MediaPlayer.OptionsApple.Resolution.Custom)
            {
                                #if UNITY_2017_2_OR_NEWER
                DisplayPlatformOption(optionsVarName, _optionCustomPreferredMaxResolution);
                                #endif
            }

            EditorGUILayout.BeginHorizontal();
            DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRateApple);
            DisplayPlatformOption(optionsVarName, _optionCustomPreferredPeakBitRateUnitsApple);
            EditorGUILayout.EndHorizontal();

            DisplayPlatformOption(optionsVarName, _optionPreferredForwardBufferDuration);

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();

            // Set the flags

            if (flagsProp != null)
            {
                flagsProp.intValue = (int)flags;
            }

            if (_showUltraOptions)
            {
                SerializedProperty keyAuthProp = serializedObject.FindProperty(optionsVarName + ".keyAuth");
                if (keyAuthProp != null)
                {
                    OnInspectorGUI_HlsDecryption(keyAuthProp);
                }

                SerializedProperty httpHeadersProp = serializedObject.FindProperty(optionsVarName + ".httpHeaders.httpHeaders");
                if (httpHeadersProp != null)
                {
                    OnInspectorGUI_HttpHeaders(httpHeadersProp);
                }
            }
        }