Ejemplo n.º 1
0
        public static string GetPath(MediaPathType location)
        {
            string result = string.Empty;

            switch (location)
            {
            case MediaPathType.AbsolutePathOrURL:
                break;

            case MediaPathType.RelativeToDataFolder:
                result = Application.dataPath;
                break;

            case MediaPathType.RelativeToPersistentDataFolder:
                result = Application.persistentDataPath;
                break;

            case MediaPathType.RelativeToProjectFolder:
#if !UNITY_WINRT_8_1
                string path = "..";
#if UNITY_STANDALONE_OSX && !UNITY_EDITOR_OSX
                path += "/..";
#endif
                result = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, path));
                result = result.Replace('\\', '/');
#endif
                break;

            case MediaPathType.RelativeToStreamingAssetsFolder:
                result = Application.streamingAssetsPath;
                break;
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given a partial file path and MediaLocation, return a directory path suitable for a file browse dialog to start in
        /// </summary>
        internal static string GetBrowsableFolder(string path, MediaPathType fileLocation)
        {
            // Try to resolve based on file path + file location
            string result = Helper.GetFilePath(path, fileLocation);

            if (!string.IsNullOrEmpty(result))
            {
                if (System.IO.File.Exists(result))
                {
                    result = System.IO.Path.GetDirectoryName(result);
                }
            }

            if (!System.IO.Directory.Exists(result))
            {
                // Just resolve on file location
                result = Helper.GetPath(fileLocation);
            }
            if (string.IsNullOrEmpty(result))
            {
                // Fallback
                result = Application.streamingAssetsPath;
            }
            return(result);
        }
Ejemplo n.º 3
0
        internal static void ShowFileWarningMessages(string filePath, MediaPathType fileLocation, MediaReference mediaReference, MediaSource mediaSource, bool isAutoOpen, Platform platform)
        {
            MediaPath mediaPath = null;

            if (mediaSource == MediaSource.Path)
            {
                mediaPath = new MediaPath(filePath, fileLocation);
            }
            else if (mediaSource == MediaSource.Reference)
            {
                if (mediaReference != null)
                {
                    mediaPath = mediaReference.GetCurrentPlatformMediaReference().MediaPath;
                }
            }

            ShowFileWarningMessages(mediaPath, isAutoOpen, platform);
        }
        void ISerializationCallbackReceiver.OnAfterDeserialize()
        {
            if (!string.IsNullOrEmpty(m_VideoPath))
            {
                MediaPathType mediaPathType = MediaPathType.AbsolutePathOrURL;
                switch (m_VideoLocation)
                {
                default:
                case FileLocation.AbsolutePathOrURL:
                    mediaPathType = MediaPathType.AbsolutePathOrURL;
                    break;

                case FileLocation.RelativeToProjectFolder:
                    mediaPathType = MediaPathType.RelativeToProjectFolder;
                    break;

                case FileLocation.RelativeToStreamingAssetsFolder:
                    mediaPathType = MediaPathType.RelativeToStreamingAssetsFolder;
                    break;

                case FileLocation.RelativeToDataFolder:
                    mediaPathType = MediaPathType.RelativeToDataFolder;
                    break;

                case FileLocation.RelativeToPersistentDataFolder:
                    mediaPathType = MediaPathType.RelativeToPersistentDataFolder;
                    break;
                }
                _mediaPath   = new MediaPath(m_VideoPath, mediaPathType);
                _mediaSource = MediaSource.Path;
                m_VideoPath  = null;
            }

            /*
             * if (m_StereoPacking != _fallbackMediaHints.stereoPacking)
             * {
             *      _fallbackMediaHints.stereoPacking = m_StereoPacking;
             * }
             * if (m_AlphaPacking != _fallbackMediaHints.alphaPacking)
             * {
             *      _fallbackMediaHints.alphaPacking = m_AlphaPacking;
             * }
             */
        }
Ejemplo n.º 5
0
        public static string GetFilePath(string path, MediaPathType location)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(path))
            {
                switch (location)
                {
                case MediaPathType.AbsolutePathOrURL:
                    result = path;
                    break;

                case MediaPathType.RelativeToDataFolder:
                case MediaPathType.RelativeToPersistentDataFolder:
                case MediaPathType.RelativeToProjectFolder:
                case MediaPathType.RelativeToStreamingAssetsFolder:
                    result = System.IO.Path.Combine(GetPath(location), path);
                    break;
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
 public MediaPath(string path, MediaPathType pathType)
 {
     _pathType = pathType;
     _path     = path;
 }
Ejemplo n.º 7
0
 public MediaPath(MediaPath copy)
 {
     _pathType = copy.PathType;
     _path     = copy.Path;
 }
Ejemplo n.º 8
0
 public MediaPath()
 {
     _pathType = MediaPathType.RelativeToStreamingAssetsFolder;
     _path     = string.Empty;
 }
Ejemplo n.º 9
0
 public bool OpenMedia(MediaPathType pathType, string path, bool autoPlay = true)
 {
     return(_mediaPlayer.OpenMedia(pathType, path, autoPlay));
 }