Hi All,
I have an upload video button (#uploadVideo2) for users to upload a video of their choice. I would like a preview video (#videoPlayer1) to appear once upload is complete, however, the video doesn't seem to play as it just turns black even after trying different videos...here's my code... I have a feeling it's something to do with: $w("#videoPlayer1").src = uploadedFile.url;
export function uploadVideo2_change(event) { let file = $w('#uploadVideo2').value; if ($w("#uploadVideo2").value.length > 0) { $w("#loadingBox").show(); $w("#uploadVideo").disable(); $w("#uploadVideo2").startUpload() .then((uploadedFile) => { $w("#uploadVideo").enable(); $w("#loadingBox").hide(); $w("#videoPlayer1").show(); $w("#videoPlayer1").src = uploadedFile.url; $w("#uploadCoverPhotoMain").hide(); $w("#uploadAudio2").hide(); $w("#uploadAttachment2").hide(); $w("#uploadImage").disable(); $w("#uploadAudio").disable(); $w("#uploadAttachment").disable(); }) .catch((uploadError) => {}); $w("#uploadCoverPhotoMain").show(); $w("#uploadAudio2").show(); $w("#uploadAttachment2").show(); $w("#uploadImage").enable(); $w("#uploadAudio").enable(); $w("#uploadAttachment").enable(); } else { $w("#uploadCoverPhotoMain").show(); $w("#uploadAudio2").show(); $w("#uploadAttachment2").show(); $w("#uploadImage").enable(); $w("#uploadAudio").enable(); $w("#uploadAttachment").enable(); } }
Try this function ->
let file = $w('#uploadButton1').value; if ($w("#uploadButton1").value.length > 0) { $w("#uploadButton1").startUpload() .then((uploadedFile) => { console.log(uploadedFile.url); $w("#uploadVideo").enable(); $w("#loadingBox").hide(); $w("#videoPlayer1").show(); $w("#videoPlayer1").src = uploadedFile.url; $w("#videoPlayer1").play()
There is an issue at Wix's end and they are currently looking at this ...
I tried this code. Worked fine for me !!
(-> Please make sure that your upload button's supported file is selected to video
Click the Upload Button on your site.
Click the Settings icon
Click the Supported file type drop-down and select the file type you want the visitor to upload (Video).
https://support.wix.com/en/article/adding-and-setting-up-an-upload-button
)
export function uploadButton1_change(event) { let file = $w('#uploadButton1').value; if ($w("#uploadButton1").value.length > 0) { $w("#uploadButton1").startUpload() .then((uploadedFile) => { console.log(uploadedFile.url); $w("#uploadVideo").enable(); $w("#loadingBox").hide(); $w("#videoPlayer1").show(); $w("#videoPlayer1").src = uploadedFile.url; $w("#uploadCoverPhotoMain").hide(); $w("#uploadAudio2").hide(); $w("#uploadAttachment2").hide(); $w("#uploadImage").disable(); $w("#uploadAudio").disable(); $w("#uploadAttachment").disable(); }) .catch((err) => { console.log(err); $w("#uploadCoverPhotoMain").show(); $w("#uploadAudio2").show(); $w("#uploadAttachment2").show(); $w("#uploadImage").enable(); $w("#uploadAudio").enable(); $w("#uploadAttachment").enable(); }); } else { $w("#uploadCoverPhotoMain").show(); $w("#uploadAudio2").show(); $w("#uploadAttachment2").show(); $w("#uploadImage").enable(); $w("#uploadAudio").enable(); $w("#uploadAttachment").enable(); } }