Exemple #1
0
    void Start()
    {
        try
        {
            // Creation of the NexPlayer instance
            player = NexPlayerFactory.GetNexPlayer();
            // Register to the events of NexPlayer
            player.OnEvent += EventNotify;
            // Initialize NexPlayer with an URI
            player.Init(URL, autoPlay, extendedLogs);

            // Change the text informing the status of the player
            status.text = "Opening...";
            // The coroutine needs to be started after the player is created an initialized
            StartCoroutine(player.CoroutineEndOfTheFrame());
        }
        catch (System.Exception e)
        {
            Debug.LogError("Error while initializing the player. Please check that your platform is supported.");
            Debug.LogError("Exception: " + e);

            status.text = "Error";
            player      = null;
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (!isPlatformSupported)
        {
            EditorGUILayout.HelpBox("Platform not supported !", MessageType.Error);
        }

        else
        {
            if (isAPIsValid)
            {
                EditorGUILayout.HelpBox("All the Graphics APIs are properly set", MessageType.Info);
            }
            else
            {
                EditorGUILayout.HelpBox("There are invalid Graphics APIs. Changed them to use NexPlayer", MessageType.Warning);

                if (GUILayout.Button("Select valid Graphics APIs"))
                {
                    Debug.Log("Selecting only the valid Graphics APIs");

                    NexPlayerFactory.FixGraphicsAPIsSupported();
                    isAPIsValid = NexPlayerFactory.AreGraphicsAPIsSupported();
                }
            }

            if (!IsInternetAccessEnabled())
            {
                if (GUILayout.Button("Set Internet access to required (needed for HTTP request)"))
                {
                    PlayerSettings.Android.forceInternetPermission = true;
                }
            }

            if (!IsHTTPAllowed())
            {
                if (GUILayout.Button("Enable HTTP connections (in addition to HTTPS)"))
                {
                    PlayerSettings.iOS.allowHTTPDownload = true;
                }
            }

            if (!IsiOS8OrAbove())
            {
                if (GUILayout.Button("Set the minimum target version to iOS 8.0"))
                {
                                        #if UNITY_5_5_OR_NEWER
                    PlayerSettings.iOS.targetOSVersionString = "8.0";
                                        #else
                    PlayerSettings.iOS.targetOSVersion = iOSTargetOSVersion.iOS_8_0;
                                        #endif
                }
            }
        }
    }
    public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
    {
        if (buildTarget == BuildTarget.iOS)
        {
            // This needs to be placed in a folder named "Editor" otherwise MonoDevelop will fail to build (Not Unity)

            // That behavior is (at the time of writing this) a reported Unity issue (regression)
            // https://issuetracker.unity3d.com/issues/unity-does-not-include-unityeditor-dot-ios-dot-xcode-in-project-file

            // It can also be fixed following these steps:
            // In MonoDevelop, go under "Project" menu > "Edit References..." > ".NET Assembly" tab > Click "Browse" in lower right, and browse to your Unity install to find the dll, e.g. "/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll"

            // Original comment:
            // ETHAN_VISUALVOCALOCT 13, 2016 22:19
            // Still happening in 5.4.2f1 for me.
            // Workaround for MonoDevelop:
            // In MonoDevelop, go under "Project" menu > "Edit References..." > ".NET Assembly" tab > Click "Browse" in lower right, and browse to your Unity install to find the dll, e.g. "/Applications/Unity/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll"

            Debug.Log("NexPlayer for iOS is adding changes to the build of the XCode project");

            string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

            NexPlayer.UnityEditor.iOS.Xcode.PBXProject pbxProject = new NexPlayer.UnityEditor.iOS.Xcode.PBXProject();
            pbxProject.ReadFromFile(projectPath);

            string target = pbxProject.TargetGuidByName("Unity-iPhone");

            // Disable bitcode
            pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            // Add VideoToolbox
            pbxProject.AddFrameworkToProject(target, "VideoToolbox.framework", false /*not weak*/);

            // Add to other linker flags "-lstdc++"
            pbxProject.AddBuildProperty(target, "OTHER_LDFLAGS", "-lstdc++");

            pbxProject.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "$(inherited)");
            pbxProject.AddBuildProperty(target, "LD_RUNPATH_SEARCH_PATHS", "@executable_path/Frameworks");

            // In order to add properly the Embedded binaries we modified the open source file https://bitbucket.org/Unity-Technologies/xcodeapi
            pbxProject.AddDynamicFrameworkToProject(target, "Frameworks/Plugins/iOS/WidevineIntegration.framework");
            pbxProject.AddDynamicFrameworkToProject(target, "Frameworks/Plugins/iOS/widevine_cdm_sdk_release.framework");

            // Some extra needed files are not present on Unity 5.3 and below in the generated Xcode projects
            if (!NexPlayerFactory.IsUnityVersionEqualsOrAbove_5_4())
            {
                // Add the needed extra files
                CopyAndReplaceDirectory("Assets/Plugins/iOS/Unity/", Path.Combine(path, "Classes/Unity/"));
            }

            pbxProject.WriteToFile(projectPath);
        }
    }
 void OnEnable()
 {
     isPlatformSupported = NexPlayerFactory.IsPlatformSupported();
     isAPIsValid         = NexPlayerFactory.AreGraphicsAPIsSupported();
 }