07-18-2014 05:08 PM
Hi
Is it possible to use the preview functionality using only the DM?
I know that it is possible for DOC, PDF and image files.
In the following picture you can see my example. I have a PDF, MOV, MP3 and DOC files. We can press the preview function only for PDF, and DOC(Office) files.
When I try to preview the MP3 and MOV files the message error is:
" Preview can not be generated for this document
Technical issue:
Blob path: files:files/1/file
org.nuxeo.ecm.platform.preview.api.PreviewException: Converter any2pdf is not available"

09-04-2014 01:11 PM
Hi.
We finish this job. The Solution was to create the VideoPreviewer and AudioPreviewer (they extends AbstractPreviewer class and implements MimeTypePreviewer class).
I followed the Nuxeo document ( http://doc.nuxeo.com/display/NXDOC/Preview?src=search#Preview-MimeTypePreviewerDetails ). I contributed with these Preview classes using a config file, like these examples http://explorer.nuxeo.org/nuxeo/site/distribution/current/viewExtensionPoint/org.nuxeo.ecm.platform....
VideoPreviewer.java
public List getPreview(Blob blob, DocumentModel dm) throws PreviewException {
List blobResults = new ArrayList();
// Collect video parameters and create the Video entity
Video video = createVideo(blob);
// Converting the Video to WebM
TranscodedVideo videoTranscoded = videoService.convert(video, "WebM 480p");
File transcodedBlobFile = BlobHelper.getFileFromBlob(videoTranscoded.getBlob());
// Create the WEB_SERVER/tmp directory. We need it because the browser
// do not allow open videos from local directory
String tmpFolderPath = createTmpFolder();
// Now we have to move the Transcoded file to tmp directory
File newTranscodedBlobFile = new File(tmpFolderPath + "/" + transcodedBlobFile.getName());
try {
Files.move(transcodedBlobFile, newTranscodedBlobFile);
} catch (IOException e1) {
e1.printStackTrace();
}
//To get the transcode URL. We need it to append on the HTML code
String transcodedUrl = createTrancodedUrl(newTranscodedBlobFile);
try {
StringBuffer htmlPage = new StringBuffer();
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append(dm.getName() + " - " + blob.getFilename());
//Appending the videoJS (the video player and the transcoded URL) code into HTML page.
htmlPage = appendVideoPlayer(htmlPage, transcodedUrl);
htmlPage.append("");
Blob mainBlob = new StringBlob(htmlPage.toString());
mainBlob.setFilename("index.html");
mainBlob.setMimeType("text/html");
blobResults.add(mainBlob);
} catch (Exception e) {
throw new PreviewException("Unable to get document property", e);
}
return blobResults;
}
AudioPreviewer.java
public List getPreview(Blob blob, DocumentModel dm) throws PreviewException {
List blobResults = new ArrayList();
File audioBlobFile = BlobHelper.getFileFromBlob(blob);
// Create the WEB_SERVER/tmp directory. We need it because the browser
// do not allow open audios from local directory
String tmpFolderPath = createTmpFolder();
// Now we have to copy the Transcoded file to tmp directory
File newAudioBlobFile = new File(tmpFolderPath + "/" + audioBlobFile.getName());
try {
Files.copy(audioBlobFile, newAudioBlobFile);
} catch (IOException e1) {
e1.printStackTrace();
}
//To get the transcode URL. We need it to append on the HTML code
String audioUrl = createAudioUrl(newAudioBlobFile);
try {
StringBuffer htmlPage = new StringBuffer();
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append(dm.getName() + " - " + blob.getFilename());
//Appending the videoJS (the video player and the transcoded URL) code into HTML page.
htmlPage = appendAudioPlayer(htmlPage, audioUrl);
htmlPage.append("");
Blob mainBlob = new StringBlob(htmlPage.toString());
mainBlob.setFilename("index.html");
mainBlob.setMimeType("text/html");
blobResults.add(mainBlob);
} catch (Exception e) {
throw new PreviewException("Unable to get document property", e);
}
return blobResults;
}
The result is: from every place where Nuxeo call the "Preview" action my classes are called. I'm just using the DAM jars (audio and video)
PS: I'm not sure if the VideoPreview conversion is the best solution, but it works.
07-21-2014 10:29 AM
Hi,
This feature is provided by the DAM Marketplace Package. If you don't want the DAM interface, you can still try to deploy only the addons you're interested in: nuxeo-platform-audio and nuxeo-platform-video.
07-24-2014 10:54 AM
You're missing a third-party library (jaudiotagger-2.0.3.jar in that case) and probably a few others. That's the purpose of the Marketplace Package to also deploy the needed third-parties.
09-04-2014 01:11 PM
Hi.
We finish this job. The Solution was to create the VideoPreviewer and AudioPreviewer (they extends AbstractPreviewer class and implements MimeTypePreviewer class).
I followed the Nuxeo document ( http://doc.nuxeo.com/display/NXDOC/Preview?src=search#Preview-MimeTypePreviewerDetails ). I contributed with these Preview classes using a config file, like these examples http://explorer.nuxeo.org/nuxeo/site/distribution/current/viewExtensionPoint/org.nuxeo.ecm.platform....
VideoPreviewer.java
public List getPreview(Blob blob, DocumentModel dm) throws PreviewException {
List blobResults = new ArrayList();
// Collect video parameters and create the Video entity
Video video = createVideo(blob);
// Converting the Video to WebM
TranscodedVideo videoTranscoded = videoService.convert(video, "WebM 480p");
File transcodedBlobFile = BlobHelper.getFileFromBlob(videoTranscoded.getBlob());
// Create the WEB_SERVER/tmp directory. We need it because the browser
// do not allow open videos from local directory
String tmpFolderPath = createTmpFolder();
// Now we have to move the Transcoded file to tmp directory
File newTranscodedBlobFile = new File(tmpFolderPath + "/" + transcodedBlobFile.getName());
try {
Files.move(transcodedBlobFile, newTranscodedBlobFile);
} catch (IOException e1) {
e1.printStackTrace();
}
//To get the transcode URL. We need it to append on the HTML code
String transcodedUrl = createTrancodedUrl(newTranscodedBlobFile);
try {
StringBuffer htmlPage = new StringBuffer();
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append(dm.getName() + " - " + blob.getFilename());
//Appending the videoJS (the video player and the transcoded URL) code into HTML page.
htmlPage = appendVideoPlayer(htmlPage, transcodedUrl);
htmlPage.append("");
Blob mainBlob = new StringBlob(htmlPage.toString());
mainBlob.setFilename("index.html");
mainBlob.setMimeType("text/html");
blobResults.add(mainBlob);
} catch (Exception e) {
throw new PreviewException("Unable to get document property", e);
}
return blobResults;
}
AudioPreviewer.java
public List getPreview(Blob blob, DocumentModel dm) throws PreviewException {
List blobResults = new ArrayList();
File audioBlobFile = BlobHelper.getFileFromBlob(blob);
// Create the WEB_SERVER/tmp directory. We need it because the browser
// do not allow open audios from local directory
String tmpFolderPath = createTmpFolder();
// Now we have to copy the Transcoded file to tmp directory
File newAudioBlobFile = new File(tmpFolderPath + "/" + audioBlobFile.getName());
try {
Files.copy(audioBlobFile, newAudioBlobFile);
} catch (IOException e1) {
e1.printStackTrace();
}
//To get the transcode URL. We need it to append on the HTML code
String audioUrl = createAudioUrl(newAudioBlobFile);
try {
StringBuffer htmlPage = new StringBuffer();
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append("");
htmlPage.append(dm.getName() + " - " + blob.getFilename());
//Appending the videoJS (the video player and the transcoded URL) code into HTML page.
htmlPage = appendAudioPlayer(htmlPage, audioUrl);
htmlPage.append("");
Blob mainBlob = new StringBlob(htmlPage.toString());
mainBlob.setFilename("index.html");
mainBlob.setMimeType("text/html");
blobResults.add(mainBlob);
} catch (Exception e) {
throw new PreviewException("Unable to get document property", e);
}
return blobResults;
}
The result is: from every place where Nuxeo call the "Preview" action my classes are called. I'm just using the DAM jars (audio and video)
PS: I'm not sure if the VideoPreview conversion is the best solution, but it works.
09-04-2014 02:30 PM
Thank you for the feedback.
Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.