/// <summary>
        ///  Create instance of MediaPlayerWebGL object with additional arguments
        /// </summary>
        /// <param name="monoObject">MonoBehaviour instanse</param>
        /// <param name="videoOutputObjects">Objects that will be rendering video output</param>
        /// <param name="options">Additional player options</param>
        public MediaPlayerWebGL(MonoBehaviour monoObject, GameObject[] videoOutputObjects, PlayerOptions options)
        {
            _monoObject         = monoObject;
            _videoOutputObjects = videoOutputObjects;
            _options            = options;

            _wrapper = new WrapperInternal(null);

            if (_options != null)
            {
                if (_options.FixedVideoSize != Vector2.zero)
                {
                    _videoBuffer = new PlayerBufferVideo((int)_options.FixedVideoSize.x, (int)_options.FixedVideoSize.y);
                }
            }

            _eventManager = new PlayerManagerEvents(_monoObject, this);
            _eventManager.PlayerPlayingListener += OnPlayerPlaying;
            _eventManager.PlayerPausedListener  += OnPlayerPaused;
        }
Example #2
0
#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.Instance.UseAudioSource && (_desktopAudioOutputs == null || _desktopAudioOutputs.Length <= 0))
            {
                var audioOutput = gameObject.AddComponent <UMPAudioOutput>();
                _desktopAudioOutputs = new UMPAudioOutput[] { audioOutput };
            }

            PlayerOptions options = new PlayerOptions(null);

            switch (UMPSettings.RuntimePlatform)
            {
            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)
            _videoServices = new VideoServices(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();
            }
        }
Example #3
0
        /// <summary>
        /// Create instance of media player object with additional arguments
        /// </summary>
        /// <param name="monoObject">MonoBehaviour instanse</param>
        /// <param name="videoOutputObjects">Objects that will be rendering video output</param>
        /// <param name="options">Additional player options</param>
        public MediaPlayer(MonoBehaviour monoObject, GameObject[] videoOutputObjects, PlayerOptions options)
        {
            var supportedPlatform = UMPSettings.RuntimePlatform;

            switch (supportedPlatform)
            {
            case UMPSettings.Platforms.Win:
            case UMPSettings.Platforms.Mac:
            case UMPSettings.Platforms.Linux:
                PlayerOptionsStandalone standaloneOptions = null;
                if (options is PlayerOptionsStandalone)
                {
                    standaloneOptions = options as PlayerOptionsStandalone;
                }
                else
                {
                    standaloneOptions = new PlayerOptionsStandalone(null);
                }

                _playerObject = new MediaPlayerStandalone(monoObject, videoOutputObjects, standaloneOptions);
                break;

            case UMPSettings.Platforms.iOS:
                PlayerOptionsIPhone iphoneOptions = null;
                if (options is PlayerOptionsIPhone)
                {
                    iphoneOptions = options as PlayerOptionsIPhone;
                }
                else
                {
                    iphoneOptions = new PlayerOptionsIPhone(null);
                }

                _playerObject = new MediaPlayerIPhone(monoObject, videoOutputObjects, iphoneOptions);
                break;

            case UMPSettings.Platforms.Android:
                PlayerOptionsAndroid androidOptions = null;
                if (options is PlayerOptionsAndroid)
                {
                    androidOptions = options as PlayerOptionsAndroid;
                }
                else
                {
                    androidOptions = new PlayerOptionsAndroid(null);
                }

                _playerObject = new MediaPlayerAndroid(monoObject, videoOutputObjects, androidOptions);
                break;

                /*
                 * case UMPSettings.Platforms.WebGL:
                 * _playerObject = new MediaPlayerWebGL(monoObject, videoOutputObjects, options);
                 * break;*/
            }

            if (_playerObject is IPlayer)
            {
                _player = (_playerObject as IPlayer);
            }

            if (_playerObject is IPlayerAudio)
            {
                _playerAudio = (_playerObject as IPlayerAudio);
            }

            if (_playerObject is IPlayerSpu)
            {
                _playerSpu = (_playerObject as IPlayerSpu);
            }
        }