Beispiel #1
0
        private void Open()
        {
            string path   = m_path;
            long   offset = 0;
            long   length = 0;

            if (!m_absolutePath)
            {
                switch (Application.platform)
                {
                case RuntimePlatform.Android:
                    path = Application.dataPath;

                    if (!AssetStream.GetZipFileOffsetLength(Application.dataPath, m_path, out offset, out length))
                    {
                        throw new System.Exception("problem opening movie");
                    }
                    break;

                default:
                    path = Application.streamingAssetsPath + "/" + m_path;
                    break;
                }
            }


#if UNITY_EDITOR
            if (!SanityCheckPath(path))
            {
                throw new System.Exception("Can't find video at path" + path);
            }
#endif //UNITY_EDITOR

            //No platform should need power of 2 textures anymore
            const bool powerOf2Textures = false;

            //This is maximum frames decoded/uploaded
            const int maxSkipFrames = 16;

            if (m_nativeContext != IntPtr.Zero && OpenStream(m_nativeContext, path, (int)offset, (int)length, powerOf2Textures, m_scanDuration, maxSkipFrames))
            {
                m_picWidth  = GetPicWidth(m_nativeContext);
                m_picHeight = GetPicHeight(m_nativeContext);

                m_picX = GetPicX(m_nativeContext);
                m_picY = GetPicY(m_nativeContext);

                int yStride  = GetYStride(m_nativeContext);
                int yHeight  = GetYHeight(m_nativeContext);
                int uvStride = GetUVStride(m_nativeContext);
                int uvHeight = GetUVHeight(m_nativeContext);

                m_yStride  = yStride;
                m_yHeight  = yHeight;
                m_uvStride = uvStride;
                m_uvHeight = uvHeight;

                CalculateUVScaleOffset();
            }
            else
            {
                throw new System.Exception("problem opening movie");
            }
        }