Binary101010
Binary101010

Reputation: 580

Vimeo PUT Uploader

So I found this awesome plugin for using PUT uploads to Vimeo. https://github.com/websemantics/vimeo-upload

I love it. I did however have a question on how to add in the: upgrade_to_1080 option as a parameter?

Could you give me a quick example of this?

I have looked in the source for an example of it and found nothing explaining this as an option but I assume it can be added as a parameter I am just not sure how exactly.

Here is the snippet I use and would assume this parameter would go:

function handleFileSelect(evt) {
     evt.stopPropagation();
     evt.preventDefault();
     var files = evt.dataTransfer.files; // FileList object.
     var accessToken = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX';
     updateProgress(0);

     var uploader = new MediaUploader({
         file: files[0],
         token: accessToken,
         onError: function(data) {
             console.log('Error');
         },
         onProgress: function(data) {
            updateProgress(data.loaded / data.total);
         },
         onComplete: function(videoId) {

            var url = "https://vimeo.com/"+videoId;

            var a = document.createElement('a');
            a.appendChild(document.createTextNode(url));
            a.setAttribute('href',url);

            var element = document.createElement("div");
            element.setAttribute('class', "alert alert-success");
            element.appendChild(a);

            document.getElementById('results').appendChild(element);

            //show form
            $('.add-video').show();
            $('.vimeo_id').val(videoId);

            //add vimeo video to video table ASAP
            $.ajax({
    type : "POST",
    url : "video-management/uploader/ajax/insert.php?initial=yes",
    data : {
        'vimeo_id' : videoId
    },
    beforeSend : function() {
        //show spinning icon while script is processing
        $('#loadModal').modal('show');
    },
    success : function(data) {
        $('#loadModal').modal('hide');
        $('.initial-load').show().html(data);
    }
});

              $.ajax({
    type : "GET",
    url : "video-management/uploader/ajax/related-videos.php",
    beforeSend : function() {
        //show spinning icon while script is processing
        //$('#loadModal').modal('show');
    },
    success : function(data) {
        //$('#loadModal').modal('hide');
        $('.load-related').hide();
        $('.related').html(data);

    }
});

         }
     });
     uploader.upload();
   }

I also took a look at the upload.js file and I see this:

xhr.onerror = this.onUploadError_.bind(this);
  xhr.send(JSON.stringify({
  type:'streaming'
  }));

Would I add the option here?

Thanks!

Upvotes: 0

Views: 572

Answers (1)

Adnan
Adnan

Reputation: 211

Yes, that should do it, ..

xhr.onerror = this.onUploadError_.bind(this);
xhr.send(JSON.stringify({
type:'streaming',
upgrade_to_1080: true
}));

Upvotes: 1

Related Questions