#pragma warning restore 0414 private void Awake() { #if UNITY_EDITOR #if UNITY_4 || UNITY_5 || UNITY_2017_1 EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged; #else EditorApplication.playModeStateChanged += HandleOnPlayModeChanged; #endif #endif if (UMPSettings.GetSettings().UseAudioSource&& (_desktopAudioOutputs == null || _desktopAudioOutputs.Length <= 0)) { var audioOutput = gameObject.AddComponent <UMPAudioOutput>(); _desktopAudioOutputs = new UMPAudioOutput[] { audioOutput }; } PlayerOptions options = new PlayerOptions(null); switch (UMPSettings.SupportedPlatform) { case UMPSettings.Platforms.Win: case UMPSettings.Platforms.Mac: case UMPSettings.Platforms.Linux: var standaloneOptions = new PlayerOptionsStandalone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, AudioOutputs = _desktopAudioOutputs, //DirectAudioDevice = "Digital Audio", HardwareDecoding = _desktopHardwareDecoding, FlipVertically = _desktopFlipVertically, VideoBufferSize = _desktopVideoBufferSize, UseTCP = _desktopRtspOverTcp, FileCaching = _desktopFileCaching, LiveCaching = _desktopLiveCaching, DiskCaching = _desktopDiskCaching, NetworkCaching = _desktopNetworkCaching }; if (_desktopOutputToFile) { standaloneOptions.RedirectToFile(_desktopDisplayOutput, _desktopOutputFilePath); } standaloneOptions.SetLogDetail(_logDetail, UnityConsoleLogging); options = standaloneOptions; break; case UMPSettings.Platforms.Android: var androidOptions = new PlayerOptionsAndroid(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, PlayerType = _androidPlayerType, HardwareAcceleration = _androidHardwareAcceleration, OpenGLDecoding = _androidOpenGLDecoding, VideoChroma = _androidVideoChroma, PlayInBackground = _androidPlayInBackground, UseTCP = _androidRtspOverTcp, NetworkCaching = _androidNetworkCaching }; options = androidOptions; if (_exportedHandlerEnum == null) { _exportedHandlerEnum = AndroidExpoterdHandler(); StartCoroutine(_exportedHandlerEnum); } break; case UMPSettings.Platforms.iOS: var iphoneOptions = new PlayerOptionsIPhone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, PlayerType = _iphonePlayerType, FlipVertically = _iphoneFlipVertically, VideoToolbox = _iphoneVideoToolbox, VideoToolboxFrameWidth = _iphoneVideoToolboxMaxFrameWidth, VideoToolboxAsync = _iphoneVideoToolboxAsync, VideoToolboxWaitAsync = _iphoneVideoToolboxWaitAsync, PlayInBackground = _iphonePlayInBackground, UseTCP = _iphoneRtspOverTcp, PacketBuffering = _iphonePacketBuffering, MaxBufferSize = _iphoneMaxBufferSize, MinFrames = _iphoneMinFrames, Infbuf = _iphoneInfbuf, Framedrop = _iphoneFramedrop, MaxFps = _iphoneMaxFps }; options = iphoneOptions; break; } _mediaPlayer = new MediaPlayer(this, _renderingObjects, options); // Create scpecial parser to add possibiity of get video link from different video hosting servies (like youtube) _videoHostingParser = new VideoHostingParser(this); // Attach scecial listeners to MediaPlayer instance AddListeners(); // Create additional media player for add smooth loop possibility if (_loopSmooth) { _mediaPlayerLoop = new MediaPlayer(this, _mediaPlayer); _mediaPlayerLoop.VideoOutputObjects = null; _mediaPlayerLoop.EventManager.RemoveAllEvents(); } }
#pragma warning restore 0414 private void Awake() { #if UNITY_EDITOR EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged; #endif if (UMPSettings.Instance.UseAudioSource && (_audioSourcesDesktop == null || _audioSourcesDesktop.Length <= 0)) { var audioOutput = gameObject.AddComponent <AudioSource>(); _audioSourcesDesktop = new AudioSource[] { audioOutput }; } PlayerOptions options = new PlayerOptions(null); switch (UMPSettings.SupportedPlatform) { case UMPSettings.Platforms.Win: case UMPSettings.Platforms.Mac: case UMPSettings.Platforms.Linux: if (UMPSettings.EditorBitMode == UMPSettings.BitModes.x86 && _hardwareDecodingDesktop == PlayerOptions.State.Default) { _hardwareDecodingDesktop = PlayerOptions.State.Enable; } var standaloneOptions = new PlayerOptionsStandalone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, AudioOutputSources = _audioSourcesDesktop, HardwareDecoding = _hardwareDecodingDesktop, FlipVertically = _flipVerticallyDesktop, UseTCP = _rtspOverTcpDesktop, FileCaching = _fileCachingDesktop, LiveCaching = _liveCachingDesktop, DiskCaching = _diskCachingDesktop, NetworkCaching = _networkCachingDesktop }; if (_outputToFileDesktop) { standaloneOptions.RedirectToFile(_displayOutputDesktop, _outputFilePathDesktop); } standaloneOptions.SetLogDetail(_logDetail, UnityConsoleLogging); options = standaloneOptions; break; case UMPSettings.Platforms.Android: var androidOptions = new PlayerOptionsAndroid(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, HardwareDecoding = _hardwareDecodingAndroid, PlayInBackground = _playInBackgroundAndroid, UseTCP = _rtspOverTcpAndroid, FileCaching = _fileCachingAndroid, LiveCaching = _liveCachingAndroid, DiscCaching = _diskCachingAndroid, NetworkCaching = _networkCachingAndroid }; options = androidOptions; break; case UMPSettings.Platforms.iOS: var iphoneOptions = new PlayerOptionsIPhone(null) { FixedVideoSize = _useFixedSize ? new Vector2(_fixedVideoWidth, _fixedVideoHeight) : Vector2.zero, VideoToolbox = _videoToolboxIPhone, VideoToolboxFrameWidth = _videoToolboxMaxFrameWidthIPhone, VideoToolboxAsync = _videoToolboxAsyncIPhone, VideoToolboxWaitAsync = _videoToolboxWaitAsyncIPhone, PlayInBackground = _playInBackgroundIPhone, UseTCP = _rtspOverTcpIPhone, PacketBuffering = _packetBufferingIPhone, MaxBufferSize = _maxBufferSizeIPhone, MinFrames = _minFramesIPhone, Infbuf = _infbufIPhone, Framedrop = _framedropIPhone, MaxFps = _maxFpsIPhone }; options = iphoneOptions; break; } _mediaPlayer = new MediaPlayer(this, _renderingObjects, options); if (_cachedVideoPaths == null) { _cachedVideoPaths = new Dictionary <string, string>(); } // Create scpecial parser to add possibiity of get video link from different video hosting servies (like youtube) _videoHostingParser = new VideoHostingParser(this); // Attach scecial listeners to MediaPlayer instance AddListeners(); // Create additional media player for add smooth loop possibility if (_loopSmooth) { _mediaPlayerLoop = new MediaPlayer(this, _mediaPlayer); _mediaPlayerLoop.VideoOutputObjects = null; _mediaPlayerLoop.EventManager.RemoveAllEvents(); } }