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();
}
}
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();
}
}
Strange! The videoplayers does work but only when not set to ‘autoplay’ on the particular page but works on a dynamic page (the repaters we were talking about before). The upload button is set to video and does upload the video, however, if the video player it set to ‘autoplay’ it works for 2 seconds and then just turns black and not playable. Do you think it has anything to do with the src?
@events32996 Just try uploading another video !!
And what do you mean by " The upload button is set to video "
@ajithkrr tried that many times! So the video plays if the autoplay option is off, so it’s not the video that’s the issue. I would like the video to automatically play, however, this triggers the videoplayer not to play - seems like a glitch of some kind
There is an issue at Wix’s end and they are currently looking at this …
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()