Exemplo n.º 1
0
    private void Awake()
    {
#if UNITY_EDITOR
        EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
#endif
        _mediaPlayer = new MediaPlayer(this, _renderingObjects, new PlayerArguments(null)
        {
            UseNativePlayer    = PreloadedSettings.Instance.UseAndroidNative,
            AudioOutputSources = _audioSources,
            FileCaching        = _fileCaching,
            LiveCaching        = _liveCaching,
            DiskCaching        = _diskCaching,
            NetworkCaching     = _networkCaching,
            HardwareDecoding   = PlayerArguments.ArgsState.Default,
        });

#if UNITY_EDITOR
        if (_mediaPlayer.PlatformPlayer is MediaPlayerStandalone)
        {
            _logManager = (_mediaPlayer.PlatformPlayer as MediaPlayerStandalone).LogManager;
            if (_logManager != null)
            {
                // Set delegate for LogManager to show native library logging in Unity console
                _logManager.LogMessageListener += UnityConsoleLogging;
                // Set debugging level
                _logManager.LogDetail = _logDetail;
            }
        }
#endif
        // 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();
    }
Exemplo n.º 2
0
    private void Awake()
    {
#if UNITY_EDITOR
        EditorApplication.playmodeStateChanged += HandleOnPlayModeChanged;
#endif

        if (PreloadedSettings.Instance.UseAudioSource && (_audioSources == null || _audioSources.Length <= 0))
        {
            var audioOutput = gameObject.AddComponent <AudioSource>();
            _audioSources = new AudioSource[] { audioOutput };
        }

        _mediaPlayer = new MediaPlayer(this, _renderingObjects, new PlayerArguments(null)
        {
            UseNativePlayer    = PreloadedSettings.Instance.UseAndroidNative,
            AudioOutputSources = _audioSources,
            FileCaching        = _fileCaching,
            LiveCaching        = _liveCaching,
            DiskCaching        = _diskCaching,
            NetworkCaching     = _networkCaching,
            HardwareDecoding   = PlayerArguments.ArgsState.Default
        });

#if UNITY_EDITOR
        if (_mediaPlayer.PlatformPlayer is MediaPlayerStandalone)
        {
            _logManager = (_mediaPlayer.PlatformPlayer as MediaPlayerStandalone).LogManager;
            if (_logManager != null)
            {
                // Set delegate for LogManager to show native library logging in Unity console
                _logManager.LogMessageListener += UnityConsoleLogging;
                // Set debugging level
                _logManager.LogDetail = _logDetail;
            }
        }
#endif
        // 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();
        }
    }