• Post Reply Bookmark Topic Watch Topic
  • New Topic

how can I invoke a JSF bean method on a GET to get the video?

 
yassine amira
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to upload video files automatically that were recording on my WildFly server. This is my code. How can I upload the video on my server? how can I invoke a JSF bean method on a GET to get the video?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form id="form">
<div>
<h:button id='request' value="Request Camera">

</h:button>
<h:button id='start' value=" Start Recording">
</h:button>
<h:button id='stop' value="Stop Recording">

</h:button>
<h:inputText type="text" id="inputid" />
<a id='ul'>Downloads List: </a>
</div>
<video id='video' autoplay="autoplay"></video>
</h:form>

<script>
var video, reqBtn, startBtn, stopBtn, ul, stream, recorder;
video = document.getElementById('video');
reqBtn = document.getElementById('form:request');
startBtn = document.getElementById('form:start');
stopBtn = document.getElementById('form:stop');
ul = document.getElementById('ul');
input = document.getElementById('form:inputid');
reqBtn.onclick = requestVideo;
startBtn.onclick = startRecording;
stopBtn.onclick = stopRecording;
startBtn.disabled = true;
ul.style.display = 'none';
stopBtn.disabled = true;

function requestVideo() {
navigator.mediaDevices.getUserMedia({
video: true,audio: true}).then(stm => {
stream = stm;
reqBtn.style.display = 'none';
startBtn.removeAttribute('disabled');
video.src = URL.createObjectURL(stream);
}).catch(e = > console.error(e));
}

function startRecording() {
recorder = new MediaRecorder(stream, {
mimeType: 'video/mp4'});
recorder.start();
stopBtn.removeAttribute('disabled');
startBtn.disabled = true;
}

function stopRecording() {
recorder.ondataavailable =e => {
ul.style.display = 'block';
var a = document.createElement('a'), li = document.createElement('li'), myObject, newpath;
a.download = ['video_', (new Date() + '').slice(4, 28), '.flv'].join('');
a.href = URL.createObjectURL(e.data);
a.textContent = a.download;
li.appendChild(a);
ul.appendChild(li);
input = e.Date;
console.log(e.data);
console.log(input);
};
recorder.stop();
startBtn.removeAttribute('disabled');
stopBtn.disabled = true;
}
</script>
</h:body>
</html>
 
Tim Holloway
Bartender
Posts: 18415
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Yassine!

There's a "Code" button on our message editor that you can use to wrap special tags around pre-formatted data (like Java code or XML). It makes the code easier to read and prevents the HTML process from ruining the natural spacing.

I'm not clear on your uploading process. JSF does have the ability to upload files (including video files) from a client. It does not support things like having the server directly manage a video source such as a camera or video recorder device. As a general rule, nothing HTML-based can do that.
 
Chris Ernst
Greenhorn
Posts: 29
MySQL Database Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm i didn't know if is this what you want...



on the fileuploadlistener you can set the path of the file wich you want to upload

maybe it helps you

cheers

Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!