When using mediaplayer with filenames containing extension different than 3 leters (eg ts, divx) the subtitles don't work.
The issue most probably is (the assumption) inside servicemp3.cpp that extension is 3 leters. http://openpli.git.s...7881f36a3c909da
337 char srt_filename[strlen(filename)+1]; 338 strncpy(srt_filename,filename,strlen(filename)-3); 339 srt_filename[strlen(filename)-3]='\0'; 340 strcat(srt_filename, "srt");
Using the following code you can see the problem and two possible ways to fix the problem:
#include <stdio.h> #include <stdlib.h> #include <string.h> void srtTest(const char*); int main(){ srtTest("/pathapath/filename.v"); srtTest("/pathapath/filename.ts"); srtTest("/pathapath/filename.avi"); srtTest("/pathapath/filename.divx"); srtTest("/pathapath/filename.mpeg4"); return 0; } void srtTest(const char *filename){ const char *ext = strrchr(filename, '.'); char srt_filename[strlen(filename)+3]; printf("Filename: %s:%d Extension: %s:%d\n", filename, strlen(filename), ext, strlen(ext)); strncpy(srt_filename,filename,strlen(filename)-3); srt_filename[strlen(filename)-3] = '\0'; strcat(srt_filename, "srt"); printf("Subtitle Len: %d CopyTo: %d (%s)\n", strlen(filename)+1, strlen(filename)-3, srt_filename); strncpy(srt_filename,filename,strlen(filename)-strlen(ext)+1); srt_filename[strlen(filename)-strlen(ext)+1] = '\0'; strcat(srt_filename, "srt"); printf("Subtitle Len: %d CopyTo: %d (%s)\n", strlen(filename)-strlen(ext)+5, strlen(filename)-strlen(ext)+1, srt_filename); strncpy(srt_filename,filename, (size_t)(ext - filename + 1)); srt_filename[ext - filename + 1] = '\0'; strcat(srt_filename, "srt"); printf("Subtitle Len: %d CopyTo: %d (%s)\n", ext - filename + 5, ext - filename +1, srt_filename); printf(" -=-=-=-=-=-=-=-=-=-\n"); } # Save as openpliTestSrv.c and complile... # gcc openpliTestSrt.c && ./a.out Filename: /pathapath/filename.v:21 Extension: .v:2 Subtitle Len: 22 CopyTo: 18 (/pathapath/filenamsrt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) -=-=-=-=-=-=-=-=-=- Filename: /pathapath/filename.ts:22 Extension: .ts:3 Subtitle Len: 23 CopyTo: 19 (/pathapath/filenamesrt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) -=-=-=-=-=-=-=-=-=- Filename: /pathapath/filename.avi:23 Extension: .avi:4 Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) -=-=-=-=-=-=-=-=-=- Filename: /pathapath/filename.divx:24 Extension: .divx:5 Subtitle Len: 25 CopyTo: 21 (/pathapath/filename.dsrt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) -=-=-=-=-=-=-=-=-=- Filename: /pathapath/filename.mpeg4:25 Extension: .mpeg4:6 Subtitle Len: 26 CopyTo: 22 (/pathapath/filename.mpsrt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) Subtitle Len: 24 CopyTo: 20 (/pathapath/filename.srt) -=-=-=-=-=-=-=-=-=-
Probably taking into consideration the extension length the subtitle filename with be calculated correctly.
The adobe issue was discovered after searching the possible subtitles that mediaplayer can handle. According to the above code mediaplayer can only handle srt subtitles because we are searching only for filename.srt.
Question?
Can we introduce one more check? (Eg for filename.usrt).
//make an extra check for ustr (uft-8 srt) if (stat(usrt_filename, &buffer) == 0){ ... } else if (stat(srt_filename, &buffer) == 0) { ....
The reason for this enchancement is to keep two version of subtitles one in iso format (eg filename.srt iso-8859-7) and the other in utf-8 format (eg filename.usrt utf-8).
Having the option for filename.usrt you can use the same (external usb) hard disk in other media players that do not support utf-8 subtitles without the need of convertion (from iso to utf-8 and versa).
Thanks,