Skip to content

Commit

Permalink
mediaresourcestream which works with byte ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
remstef committed Jun 9, 2017
1 parent 78aefd0 commit 07c2094
Show file tree
Hide file tree
Showing 5 changed files with 358 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void createTranscriptLayer(Project aProject)
playbuttonSegmentLayer.setReadonly(false);
playbuttonSegmentLayer.setMultipleTokens(false);
// playbuttonSegmentLayer.setZeroWidthOnly(true);
playbuttonSegmentLayer.setOnClickJavascriptAction("window.open('partitur/${PID}/${DOCID}#${AnchorID}')");
playbuttonSegmentLayer.setOnClickJavascriptAction("window.open('partitur/${PID}/${DOCID}#${AnchorID}', 'partitur')");
annotationService.createLayer(playbuttonSegmentLayer);

AnnotationFeature playbuttonSegmentLayerInfoFeature = new AnnotationFeature();
Expand Down Expand Up @@ -100,7 +100,7 @@ private void createTranscriptLayer(Project aProject)
playbuttonLayerInfoFeature.setName("Info");
playbuttonLayerInfoFeature.setType(CAS.TYPE_NAME_STRING);
playbuttonLayerInfoFeature.setProject(aProject);
playbuttonLayerInfoFeature.setUiName("Info");
playbuttonLayerInfoFeature.setUiName("window.open('partitur/${PID}/${DOCID}#${AnchorID}', 'partitur')");
playbuttonLayerInfoFeature.setLayer(playbuttonLayer);
annotationService.createFeature(playbuttonLayerInfoFeature);
/* END: add play buttons */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,8 @@ public ExmaraldaPartitur(PageParameters params) {
video.setPoster(new PackageResourceReference(getClass(), "no-video.jpg"));
List<DocumentToMediaMapping> media_files = mediaService.listDocumentMediaMappings(pid, did);
if(media_files.size() > 0){
Mediaresource mfile = media_files.get(0).getMedia();

// media_url = urlFor(new MediaResourceReference(), new PageParameters().add(MediaResourceStreamResource.PAGE_PARAM_PROJECT_ID, pid).add(MediaResourceStreamResource.PAGE_PARAM_FILE_ID, mfile.getId()));
// Source source = new Source("mediasource", new PackageResourceReference(getClass(), "video.webm"));
// source.setType("video/webm");

Mediaresource mfile = media_files.get(0).getMedia();
// media_url = urlFor(new MediaResourceReference(), new PageParameters().add(MediaResourceStreamResource.PAGE_PARAM_PROJECT_ID, pid).add(MediaResourceStreamResource.PAGE_PARAM_FILE_ID, mfile.getId()));
Source source = new Source("mediasource", new MediaResourceReference(), new PageParameters().add(MediaResourceStreamResource.PAGE_PARAM_PROJECT_ID, pid).add(MediaResourceStreamResource.PAGE_PARAM_FILE_ID, mfile.getId()));
source.setType(mfile.getContentType());
source.setDisplayType(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.IOException;

import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.ContentDisposition;
import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.spring.injection.annot.SpringBean;
Expand All @@ -27,34 +26,56 @@ public MediaResourceReference() {

@Override
public IResource getResource() {
MediaResourceStreamResource r = new MediaResourceStreamResource(){

private static final long serialVersionUID = -1649133598549016083L;

@Override
protected ResourceResponse newResourceResponse(Attributes attributes) {
ResourceResponse r = super.newResourceResponse(attributes);
if(attributes.getParameters().getPosition("dl") >= 0)
r.setContentDisposition(ContentDisposition.ATTACHMENT);
return r;
}

MediaResourceStreamResource r = new MediaResourceStreamResource() {

private static final long serialVersionUID = 2888522092626490637L;

@Override
public Mediaresource getMediaresource(PageParameters params){
final long pid = params.get(PAGE_PARAM_PROJECT_ID).toLong();
final long fid = params.get(PAGE_PARAM_FILE_ID).toLong();
public Mediaresource getMediaresource(PageParameters params) {
final long pid = params.get(MediaResourceStreamResource.PAGE_PARAM_PROJECT_ID).toLong();
final long fid = params.get(MediaResourceStreamResource.PAGE_PARAM_FILE_ID).toLong();
return mediaService.getMedia(pid, fid);
}

@Override
public File getFile(Mediaresource mfile) throws IOException {
return mediaService.getFile(mfile);
public File getMediaFile(Mediaresource media) throws IOException {
return mediaService.getFile(media);
}

};

return r;



// MediaResourceStreamResource r = new MediaResourceStreamResource(){
//
// private static final long serialVersionUID = -1649133598549016083L;
//
// @Override
// protected ResourceResponse newResourceResponse(Attributes attributes) {
// ResourceResponse r = super.newResourceResponse(attributes);
// if(attributes.getParameters().getPosition("dl") >= 0)
// r.setContentDisposition(ContentDisposition.ATTACHMENT);
// return r;
// }
//
// @Override
// public Mediaresource getMediaresource(PageParameters params){
// final long pid = params.get(PAGE_PARAM_PROJECT_ID).toLong();
// final long fid = params.get(PAGE_PARAM_FILE_ID).toLong();
// return mediaService.getMedia(pid, fid);
// }
//
// @Override
// public File getFile(Mediaresource mfile) throws IOException {
// return mediaService.getFile(mfile);
// }
//
// };
//
// return r;


// final long pid = 1;//params.get(PAGE_PARAM_PROJECT_ID).toLong();
// final long fid = 1;//params.get(PAGE_PARAM_FILE_ID).toLong();
Expand Down
Loading

0 comments on commit 07c2094

Please sign in to comment.