• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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>
 
Saloon Keeper
Posts: 22483
151
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
Ranch Hand
Posts: 57
Netbeans IDE MySQL Database Java
  • 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
 
I want my playground back. Here, I'll give you this tiny ad for it:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic