【问题标题】:Trying to upload video and change have video player reflect it on the form page尝试上传视频并更改让视频播放器将其反映在表单页面上
【发布时间】:2014-11-15 23:51:35
【问题描述】:

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

这是更改通过会话变量上传后添加视频路径的代码。我添加了 video.load();认为这样可以解决问题,但不确定如何让视频反映其 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();

【问题讨论】:

  • 上传完成后,您应该将 blob 存储到集合中。添加一个template autorun,它将在您刚刚更新的文档被修改时运行。修改后,您应该使用 jquery 将一个新的 source 值附加到您的 video 元素(如果它还没有)。最后,拨打video.load

标签: javascript video meteor


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多