Ejemplo n.º 1
0
    private string preparedNewVideoName;    // 暂存视频名,播放成功的才会被赋值给 CurrentVideoName
    public void Play(string name)
    {
        // 已经显示 Video
        if (canvasGroup.alpha > 0 && CurrentVideoName == name)
        {
            Click();
            return;
        }

        Show();
        ShowMask();
        HideFailTip();

        preparedNewVideoName = name;
        UrlPlay("file://" + VideoResourceAPI.FillVideoPath(name));
    }
Ejemplo n.º 2
0
    // 加载缩略图,若丢失缩略图则尝试生成
    private Sprite LoadThumbnail(string imageName)
    {
        Sprite sprite = null;
        string path   = Path.Combine(ThumbPath, imageName) + ImageSuffix;

        sprite = ResourceLoader.LoadSprite(path);
        if (sprite == null)
        {
            GameObject.Find("GetImage").GetComponent <GetImage>().GeneratePreviewImage(
                VideoResourceAPI.FillVideoPath(imageName),
                Path.Combine(Application.dataPath, "Resources", ThumbPath) + "/"
                );
            StartCoroutine(ReloadEmptySprite());
        }
        return(sprite);
    }
Ejemplo n.º 3
0
    // 播放图片
    public void PlayImage(string name)
    {
        Stop();
        Show();
        HideMask();
        HideFailTip();

        string    fullPath = VideoResourceAPI.FillVideoPath(name);
        Texture2D texture  = ResourceLoader.LoadTexture(fullPath);

        VideoRawImage.texture = texture;
        CurrentImageName      = name;

        if (AutoResize)
        {
            Resize(texture.width, texture.height);
        }
    }
Ejemplo n.º 4
0
    // outPath: Resource 下的路径
    private static void OpenFile(string outDir, string prefix)
    {
        FileOpenDialog dialog = new FileOpenDialog();

        dialog.structSize = Marshal.SizeOf(dialog);

        dialog.filter = ".mp4\0*.mp4";

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

        dialog.maxFile = dialog.file.Length;

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

        dialog.maxFileTitle = dialog.fileTitle.Length;

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

        dialog.title = "Open File Dialog";

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

        if (DialogShow.GetOpenFileName(dialog))
        {
            string destDir   = Application.dataPath + "/Resources/" + outDir + "/Videos/";
            string videoName = prefix + "_" + dialog.fileTitle;
            File.Copy(dialog.file, destDir + videoName, true);
            Debug.Log("复制成功:" + destDir + videoName);

            GameObject.Find("GetImage").GetComponent <GetImage>().GeneratePreviewImage(
                VideoResourceAPI.FillVideoPath(videoName),
                Application.dataPath + "/Resources/" + outDir + "/Thumbnails/"
                );
        }
    }