示例#1
0
    //for windows....
    private string GetPreviewTextureFullpathOfVideo(string videoFullpath)
    {
        //int filesuffixPos = videoFullpath.IndexOf (".");
        //int filenamePos = videoFullpath.LastIndexOf ("/");

        return(FileListModel.GetDataPath() + "/" + FileListModel.GetFileShortName(videoFullpath) + ".png");
    }
示例#2
0
    //filter字段: Video: mov, .mpg, .mpeg, .mp4,.avi, .asf, wmv, webm格式...
    //https://baike.baidu.com/item/OPENFILENAME/1166193?fr=aladdin...
    public void VideoFileSelect()
    {
        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 = objectThread.UnityFullpath;        //默认路径

        ofn.title = "Open Video";

        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);
            string filename = Utility.StrictLinuxStyle(ofn.file);
            ofn.file = filename;

            //must not duplicate...
            string shortName = FileListModel.GetFileShortName(filename);
            //Debug.Log( "Selected file with full path: " + filename + " : shortName:" + shortName);
            if (FileListControl.Instance().GetFileListView(shortName) != null)
            {
                return;
            }

            FileItem item = new FileItem();
            item._fileInfo = new OpenFileNameEx(ofn);
            item._fileType = FileItem.FileType.FileType_Video;

            lock ( objectThread ) {
                FileListControl.Instance().AddFile(item);
                objectThread.BUnityWorkMutex = true;
                objectThread.UnityFullpath   = filename;
            }
            //file path must convert for url path...
            //VideoPreviewer.Instance().StartPreview  ("file:///C:/Unity3d/dangmu/dangmu/Assets/Dangmu/Textures/WeChat_20180305193437.mp4", PreViewDone);
            //StartCoroutine ( WaitLoadTexture(ofn.file) );

            /*VideoPreviewer.Instance().StartPreview  (filename, PreViewDone);
             * merialDlg.Hide ();*/
        }
        Thread.CurrentThread.Abort();
    }
示例#3
0
    /// <summary>
    /// Creates the preview sprite for video.
    /// </summary>
    /// <param name="filePath">File path.</param>
    /// <param name="sprite">Sprite.</param>
    public void CreatePreviewSprite(string filePath, Sprite sprite)
    {
        string   filename = FileListModel.GetFileShortName(filePath);
        FileItem file     = fileModel.GetFileInfo(filename);

        Debug.Log("CreatePreviewSprite: name:" + filename + "###file:" + file + "###fileinfo.file:" + file._fileInfo.file);
        //dicVideoSpriteList.Add (filename, sprite);
        AddPreViewSprite(filename, sprite);
        FileListView instance = FileListView.Create(filename, file._title, sprite);

        instance.fileListModel = file;
        AddFileListView(filename, instance);
        //viewDic.Add (filename, instance);
        fileModel.Save();
        RefreshFileList();
    }
    //init to set ..

    /*
     * public void SetSprite(int index, Sprite previewSprite)
     * {
     *      this.index = index;
     *      previewImage.sprite = previewSprite;
     * }*/

    public void OnClick(GameObject objSender)
    {
        switch (objSender.name)
        {
        case "PreviewBtn":         //Open Material Window..
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                SCMainWinController.Instance().TopLeftVw.DisplayVideo(fileListModel._fileInfo.file, title);
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                SCMainWinController.Instance().TopLeftVw.DisplayWeb(fileListModel._webUrl, title);
            }
            break;

        case "ProjectBtn":         //..
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                SCMainWinController.Instance().TopRhtVw.DisplayVideo(fileListModel._fileInfo.file, title,
                                                                     SCMainWinController.Instance().TopLeftVw.GetVideoFrameCount());
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                SCMainWinController.Instance().TopRhtVw.DisplayWeb(fileListModel._webUrl, title);
            }
            break;

        case "RemoveBtn":         //移除...
            string key = "";
            if (fileListModel._fileType == FileItem.FileType.FileType_Video)
            {
                key = FileListModel.GetFileShortName(fileListModel._fileInfo.file);
            }
            else if (fileListModel._fileType == FileItem.FileType.FileType_Web)
            {
                key = FileListModel.GetUrlShortName(fileListModel._webUrl);
            }
            FileListControl.Instance().ClickRemovePreview(key);
            break;

        default:
            break;
        }
    }