Example #1
0
        private void BeginGenerateThumbnails()
        {
            EditorApplication.update -= UpdateGenerateThumbnail;

            Debug.Assert(_thumbnailPlayer == null);
                        #if UNITY_EDITOR_WIN
            if (WindowsMediaPlayer.InitialisePlatform())
            {
                MediaPlayer.OptionsWindows options = new MediaPlayer.OptionsWindows();
                _thumbnailPlayer = new WindowsMediaPlayer(options);
            }
                        #elif UNITY_EDITOR_OSX
            {
                MediaPlayer.OptionsApple options = new MediaPlayer.OptionsApple(MediaPlayer.OptionsApple.TextureFormat.BGRA, MediaPlayer.OptionsApple.Flags.None);
                _thumbnailPlayer = new AppleMediaPlayer(options);
            }
                        #endif

            if (_thumbnailPlayer != null)
            {
                _targetIndex = 0;
                BeginNextThumbnail(0);
            }
            else
            {
                EndGenerateThumbnails(false);
            }
        }
Example #2
0
 protected void Initialise()
 {
     BaseMediaPlayer mediaPlayer = CreatePlatformMediaPlayer();
     if (mediaPlayer != null)
     {
         m_Control = mediaPlayer;
         m_Texture = mediaPlayer;
         m_Info = mediaPlayer;
         m_Player = mediaPlayer;
         m_Dispose = mediaPlayer;
     }
 }
Example #3
0
        private void EndGenerateThumbnails(bool updateAssets)
        {
            EditorApplication.update -= UpdateGenerateThumbnail;
            if (_thumbnailPlayer != null)
            {
                _thumbnailPlayer.CloseMedia();
                _thumbnailPlayer.Dispose();
                _thumbnailPlayer = null;
            }
            _mediaFrame = -1;

            if (updateAssets)
            {
                // This forces the static preview to refresh
                foreach (Object o in this.targets)
                {
                    EditorUtility.SetDirty(o);
                    AssetPreview.GetAssetPreview(o);
                }
                AssetDatabase.SaveAssets();
            }
        }
Example #4
0
    public virtual BaseMediaPlayer CreatePlatformMediaPlayer()
    {
        BaseMediaPlayer mediaPlayer = null;

        // Setup for running in the editor (Either OSX, Windows or Linux)
#if UNITY_EDITOR
#if (UNITY_EDITOR_OSX)
#if UNITY_EDITOR_64
			mediaPlayer = new OSXMediaPlayer();
#else
			Log.Error(string.Format("[AVProVideo] Not supported on this platform {0} {1} {2} {3}.  Using null media ("[AVProVideo] 32-bit OS X Unity editor not supported.  64-bit required.");
#endif
#elif UNITY_EDITOR_WIN
        if (WindowsMediaPlayer.InitialisePlatform())
        {
            //mediaPlayer = new WindowsMediaPlayer(_optionsWindows.videoApi, 
            //    _optionsWindows.useHardwareDecoding, 
            //    _optionsWindows.useTextureMips, 
            //    _optionsWindows.hintAlphaChannel, 
            //    _optionsWindows.useLowLatency, 
            //    _optionsWindows.forceAudioOutputDeviceName, 
            //    _optionsWindows.useUnityAudio, 
            //    _optionsWindows.forceAudioResample, 
            //    _optionsWindows.preferredFilters);
            mediaPlayer = new WindowsMediaPlayer(Windows.VideoApi.MediaFoundation,
                true,
                false,
                false,
                false,
                string.Empty,
                false,
                true,
                null);

        }
#endif
#else
			// Setup for running builds
#if (UNITY_STANDALONE_WIN || UNITY_WSA_10_0 || UNITY_WINRT_8_1)
			if (WindowsMediaPlayer.InitialisePlatform())
			{
#if UNITY_STANDALONE_WIN
				mediaPlayer = new WindowsMediaPlayer(
                    _optionsWindows.videoApi, 
                    _optionsWindows.useHardwareDecoding, 
                    _optionsWindows.useTextureMips, 
                    _optionsWindows.hintAlphaChannel, 
                    _optionsWindows.useLowLatency, 
                    _optionsWindows.forceAudioOutputDeviceName, 
                    _optionsWindows.useUnityAudio, 
                    _optionsWindows.forceAudioResample, 
                    _optionsWindows.preferredFilters);
#elif UNITY_WSA_10_0
				mediaPlayer = new WindowsMediaPlayer(
                    Windows.VideoApi.MediaFoundation, 
                    _optionsWindowsUWP.useHardwareDecoding, 
                    _optionsWindowsUWP.useTextureMips, 
                    false, 
                    _optionsWindowsUWP.useLowLatency, 
                    string.Empty, 
                    _optionsWindowsUWP.useUnityAudio, 
                    _optionsWindowsUWP.forceAudioResample, 
                    _optionsWindows.preferredFilters);
#elif UNITY_WINRT_8_1
				mediaPlayer = new WindowsMediaPlayer(
                    Windows.VideoApi.MediaFoundation, 
                    _optionsWindowsPhone.useHardwareDecoding, 
                    _optionsWindowsPhone.useTextureMips, false, 
                    _optionsWindowsPhone.useLowLatency, 
                    string.Empty, 
                    _optionsWindowsPhone.useUnityAudio, 
                    _optionsWindowsPhone.forceAudioResample, 
                    _optionsWindows.preferredFilters);
#endif
			}
#elif (UNITY_STANDALONE_OSX || UNITY_IPHONE || UNITY_IOS)
#if (UNITY_IOS || UNITY_IPHONE)
			mediaPlayer = new OSXMediaPlayer(true);
#else
			mediaPlayer = new OSXMediaPlayer();
#endif
#elif (UNITY_ANDROID)
			// Initialise platform (also unpacks videos from StreamingAsset folder (inside a jar), to the persistent data path)
			if (AndroidMediaPlayer.InitialisePlatform())
			{
				mediaPlayer = new AndroidMediaPlayer(
                _optionsAndroid.useFastOesPath, 
                _optionsAndroid.showPosterFrame, 
                _optionsAndroid.videoApi,
			    _optionsAndroid.enableAudio360, 
                _optionsAndroid.audio360ChannelMode, 
                _optionsAndroid.preferSoftwareDecoder);
			}
#endif
#endif

        // Fallback
        if (mediaPlayer == null)
        {
            Log.Error(string.Format("[AVProVideo] Not supported on this platform {0} {1} {2} {3}.  Using null media player!", Application.platform, SystemInfo.deviceModel, SystemInfo.processorType, SystemInfo.operatingSystem));
        }

        return mediaPlayer;
    }