I responded to the feature request discussion in here: viewtopic.php?f=15&t=3811&p=60478 with the code below. It adds a custom header to the video-file request which tells Samsung devices to go get the subtitles from the URL specified in the header. And it also adds handling for a subtitle requests with the same way thumbnails are being handled (with the addition of file-extension in the filename since the devices seems to need it for recognizing the format). Sorry for this not being a diff but the code is added to RequestV2.java between the thumbnail and video-file handling. I've marked the additions with <addition> comments:
This code and discussion is found in viewtopic.php?f=15&t=3811&p=60478:
- Code: Select all
inputStream = dlna.getThumbnailInputStream();
// <addition>
} else if (fileName.indexOf("subtitle0000") > -1) {
output.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
output.setHeader(HttpHeaders.Names.EXPIRES, getFUTUREDATE() + " GMT");
List<DLNAMediaSubtitle> subs = dlna.getMedia().getSubtitlesCodes();
if(subs != null && !subs.isEmpty()) {
// TODO: maybe loop subs to get the requested subtitle type instead of using the first one
DLNAMediaSubtitle sub = subs.get(0);
inputStream = new java.io.FileInputStream(sub.getFile());
}
// </addition>
} else {
// This is a request for a regular file.
// If range has not been initialized yet and the DLNAResource has its
// own start and end defined, initialize range with those values before
// requesting the input stream.
Range.Time splitRange = dlna.getSplitRange();
if (range.getStart() == null && splitRange.getStart() != null) {
range.setStart(splitRange.getStart());
}
if (range.getEnd() == null && splitRange.getEnd() != null) {
range.setEnd(splitRange.getEnd());
}
inputStream = dlna.getInputStream(Range.create(lowRange, highRange, range.getStart(), range.getEnd()), mediaRenderer);
// <addition>
List<DLNAMediaSubtitle> subs = dlna.getMedia().getSubtitlesCodes();
if(subs != null && !subs.isEmpty()) {
DLNAMediaSubtitle sub = subs.get(0);
int type = sub.getType();
if(type < DLNAMediaSubtitle.subExtensions.length) {
String strType = DLNAMediaSubtitle.subExtensions[type -1];
output.setHeader("CaptionInfo.sec", "http://"+PMS.get().getServer().getHost()+':'+PMS.get().getServer().getPort()+"/get/"+id+"/subtitle0000." + strType);
}
}
// </addition>
Could this be added to the codebase?
