尝试上传视频并更改让视频播放器将其反映在表单页面上

Trying to upload video and change have video player reflect it on the form page

本文关键字:视频 表单 播放器      更新时间:2023-09-26

我正在使用 meteor 和文件选择器以及 pacakge,我已经成功地让图像上传工作,但是现在我想做视频,视频上传并将其值存储在视频播放器中以供预览,但它不会更新播放器,所以当我检查它时还没有视频播放正确的路径, 如果 Meteor 热重新加载页面而不刷新,则会显示视频。

以下是更改的代码,可在通过会话变量上传后添加视频路径。我添加了视频加载();认为这样可以解决问题,不确定如何让视频反映其SRC更改并观看视频。

'click #uploadVideo':function(event, template){
    event.preventDefault();
    filepicker.pickAndStore(
        {
            mimetypes: ['video/webm'],
            multiple: false
        },{
            access:"public"
        },
        function(InkBlobs){
                                                        // the upload is now complete to filepicker - but the form hasnt persisted the values to our collection yet
        Session.set("videoId", _.last(_.first(InkBlobs).url.split("/")));
        Session.set("videoKey", _.first(InkBlobs).key);


                                                        //  once the session changes are made, the form will now have the new values, including a preview of the image uploaded
    },
    function(FPError){
        log.error(FPError.toString());
    }
);
var video = $('video');
video.load();

使用持久会话包将会话值更改为持久并重新加载页面是有效的。

     Session.setPersistent("videoId", _.last(_.first(InkBlobs).url.split("/")));
    Session.setPersistent("videoKey", _.first(InkBlobs).key);
    location.reload();