コード例 #1
0
    /// <summary>
    /// Inits the file list and init textures preview...
    /// </summary>
    public void InitFileList()
    {
        //
        DeserializeAndRead();

        //get texture...
        if (null == dicFileItems)
        {
            dicFileItems = new FileList();
        }
        List <FileItem> dicFileList = dicFileItems.lstFileItems;
        List <FileItem> deleteList  = new List <FileItem>();

        foreach (var item in dicFileList)
        {
            //if ( countIndex < item.Key )
            //countIndex = item.Key;

            //FileItem file
            if (item._fileType == FileItem.FileType.FileType_Video)
            {
                //string filePath = "file://" + item.Value.
                OpenFileNameEx fileinfo = item._fileInfo;
                string         filePath = "file:///" + fileinfo.file;
                Texture2D      texture  = VideoPreviewer.Instance().LoadTexture(filePath);
                if (texture == null)
                {
                    deleteList.Add(item);
                    continue;
                }

                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                string key    = GetFileShortName(filePath);
                FileListControl.Instance().AddPreViewSprite(key, sprite);
            }
            else if (item._fileType == FileItem.FileType.FileType_Web)
            {
                string    weburl  = item._webUrl;
                Texture2D texture = WebPreviewer.Instance().LoadTexture(weburl);
                if (texture == null)
                {
                    deleteList.Add(item);
                    continue;
                }

                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                string key    = GetUrlShortName(weburl);
                FileListControl.Instance().AddPreViewWeb(key, sprite);
            }
        }

        foreach (var itemDel in deleteList)
        {
            dicFileList.Remove(itemDel);
        }

        Save();
    }
コード例 #2
0
    public void TestLoadPicture()
    {
        Texture2D texture       = VideoPreviewer.Instance().LoadTexture("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4");
        Sprite    preViewSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height),
                                                new Vector2(0.5f, 0.5f));

        previewImage.sprite = preViewSprite;

        Debug.Log("TestLoadPicture##successed:" + preViewSprite.name);
    }
コード例 #3
0
 void Update()
 {
     if (objectThread.BUnityWorkMutex)
     {
         lock (objectThread) {
             objectThread.BUnityWorkMutex = false;
             VideoPreviewer.Instance().StartPreview(objectThread.UnityFullpath, PreViewDone);
         }
     }
 }
コード例 #4
0
 // Update is called once per frame
 void Update()
 {
     if (fileDialog.objectThread.BUnityWorkMutex)
     {
         lock (fileDialog.objectThread) {
             fileDialog.objectThread.BUnityWorkMutex = false;
             VideoPreviewer.Instance().StartPreview(fileDialog.objectThread.UnityFullpath, fileDialog.PreViewDone);
             fileDialog.merialDlg.Hide();
         }
     }
 }
コード例 #5
0
    IEnumerator CoroutineSelect()
    {
        OpenFileName ofn = new OpenFileName();

        ofn.structSize = Marshal.SizeOf(ofn);

        //三菱(*.gxw)\0*.gxw\0西门子(*.mwp)\0*.mwp\0All Files\0*.*\0\0
        ofn.filter = "All Files\0*.mp4;*.mpg\0\0";

        ofn.file = new string(new char[256]);

        ofn.maxFile = ofn.file.Length;

        ofn.fileTitle = new string(new char[64]);

        ofn.maxFileTitle = ofn.fileTitle.Length;

        ofn.initialDir = UnityEngine.Application.dataPath;       //默认路径

        ofn.title = "Open Picture";

        ofn.defExt = "mp4";                                                         //显示文件的类型
        //注意 一下项目不一定要全选 但是0x00000008项不要缺少
        ofn.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 | 0x00000008; //OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST| OFN_ALLOWMULTISELECT|OFN_NOCHANGEDIR


        if (DllComdlg.GetOpenFileName(ofn))
        {
            // StartCoroutine(WaitLoad(ofn.file));//加载图片到panle
            string filename = "file:///" + Utility.StrictLinuxStyle(ofn.file);
            Debug.Log("Selected file with full path========: " + filename);
            ofn.file = filename;

            FileItem item = new FileItem();
            item._fileInfo = new OpenFileNameEx(ofn);
            item._fileType = FileItem.FileType.FileType_Video;
            //FileListControl.Instance ().AddFile (item);

            //file path must convert for url path...
            //VideoPreviewer.Instance().StartPreview  ("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);

            lock (VideoPreviewer.Instance()) {
                VideoPreviewer.Instance().StartPreview(filename, PreViewDone);
            }
            //StartCoroutine ( WaitLoadTexture(ofn.file) );
        }
        yield return(0);
    }
コード例 #6
0
 // Use this for initialization
 void Start()
 {
     //TestLoadPicture ();
     VideoPreviewer.Instance().StartPreview("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);
     //VideoPreviewer.Instance().StartPreview ("file://C:\\Unity3d\\dangmu\\dangmu\\Assets\\Dangmu\\Textures\\WeChat_20180305193437.mp4", PreViewDone);
 }