Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Set working directory when executing external player to allow access to subtitles #1177

Open
JJD2K opened this issue Apr 16, 2024 · 30 comments
Labels
bug Something isn't working

Comments

@JJD2K
Copy link

JJD2K commented Apr 16, 2024

Problem description

I tried JustPlayer as an alternative to Nova as I have a lot of issues with stutter and passthrough and it plays really well.
I want to us the option to play with external player but JustPlayer can not load the subs when loaded from NOVA.
I have tried other players like MXPlayer and I get the same issue.

I suspect that you do not set startup directory when you launch the external app.
Can you please set the MOVIE folder as working directory for the process when starting it so that the app can see the subs?

P.S. When launching those player from a file browser like MixPlorer they can see the subtitles so I am sure that it has something to do with the way NOVA launches the app.
I really believe that this should be something very simple.

It will be great to be able to use JustPlayer until you improve NOVA playback.

Thank you.

Steps to reproduce the issue

Install JustPlayer and try to use it as external player.

Expected behavior

No response

Your phone/tablet/androidTV model

TCL C845

Operating system version

Google TV 12

Application version and app store

Latest from Google Playstore

Additional system information

No response

Debug logs

No response

@JJD2K JJD2K added the bug Something isn't working label Apr 16, 2024
@JJD2K
Copy link
Author

JJD2K commented Apr 16, 2024

It seem that processbuilder is what you have to use:
https://stackoverflow.com/questions/6811522/changing-the-working-directory-of-command-from-java

@JJD2K
Copy link
Author

JJD2K commented Apr 22, 2024

@courville
Hi
I checked your sources and they seem overly complicated in PlayUtils.java. It seems startActivity is what executes the process. I do not see any working folder set for it. I do not know how MIXplorer (https://mixplorer.com) and other file managers launch apps, but for some reason the players can see the subs when launched from them.
I doubt that the file managers pass the subs to the players. I saw in your code that you even copy the subs locally.
Can you please check this issue?

@JJD2K
Copy link
Author

JJD2K commented Apr 22, 2024

Probably the file managers use a different intent:
https://stackoverflow.com/questions/17165972/android-how-to-open-a-specific-folder-via-intent-and-show-its-content-in-a-file
most likely they use code like this:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");

if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
{
    startActivity(intent);
}
else
{
    // if you reach this place, it means there is no any file 
    // explorer app installed on your device
}```

@courville
Copy link
Contributor

courville commented Apr 27, 2024

I guess that the correct title for this issue is: pass subtitles to just player not working.
Let's try first to use just player APIs moneytoo/Player#203
Note to self: subs are passed to external player already in PlayUtils:onResumeReady.

@JJD2K
Copy link
Author

JJD2K commented Apr 27, 2024

@courville
Hi thank you very much for looking at this.
I titled it like that as it seems that there is a universal way to set working directory and this to work for all players.
I really doubt that all file manager recognize all video players and pass them subtitle files. I've used ESFileExplorer in the past before they ruined it and other file managers and all of them opened video players and they could load subtitles.
Of course I could be wrong.

Passing subs to JustPlayer is absolutely sufficient for me.
Just to remark something that I observed - when launched from NOVA , JustPlayer displays the subtitles file name in the subtitles list and it is selected, but the subs do not show. I've tried switching to other susb or none and switching back to the SRT file, but it makes no difference. It seems that the player can not access the file. Could be permission issue or wrong file path.

courville added a commit to nova-video-player/aos-Video that referenced this issue Apr 27, 2024
See nova-video-player/aos-AVP#1177

Turns out that subs were not prepared and thus not passed...
@courville
Copy link
Contributor

@JJD2K done (pending your testing).
Note that subs are passed as http streams (easier and universal): no need to set directory.

@courville
Copy link
Contributor

Oh there is another bug: only one sub file is passed. I need to fix this too before releasing.

@JJD2K
Copy link
Author

JJD2K commented Apr 27, 2024

I saw the NOVA subs code and it is quite complex - probably there is a reason for it. I saw you have code for different players etc.
I really doubt that common file managers use any application-specific code to pass subs. That is why I thought that it could be a simple matter of setting working directory which would solve the issue for all external players.
Of course you can apply the easiest fix based on the way NOVA is implemented as long as the issue is solved. Even if the fix solves the issue only for Just Player it is perfectly fine.

@JJD2K
Copy link
Author

JJD2K commented Apr 27, 2024

@courville
It seems that you are working on this.
If you want me to test something let me know.

@courville
Copy link
Contributor

@JJD2K
Copy link
Author

JJD2K commented Apr 28, 2024

@courville
Hey thank you very much!

Great progress, but has some issues.

  1. On some files it seems that NOVA messes up the encoding and subs are displayed as question marks in squares. Same files play well from MixPlorer
  2. On some files it still has the old behavior - subs name is listed and selected in Just, but it does not show it.

This could be related to point 2. as on the files that DO WORK the subs in Just are listed, but not selected - I have to select them manually and they work.

If you need more info or test files let me know by email.

Thank you for looking at this issue - I really appreciate it.

@courville
Copy link
Contributor

courville commented Apr 28, 2024

For clarification sake:

  • for 1) do you refer about the file name/subtitle title displayed by the external player? Could you share the sub and video filename so that I can reproduce
  • for 2), I will need some sample to progress as well (only sub file) (you can use my email)

Regarding your last comment, I do not activate one subtitle by default thus it needs to be selected in Just (I could fix this)

@JJD2K
Copy link
Author

JJD2K commented Apr 28, 2024

Hello
I sent you the files.

  1. No - the subs names are displayed properly, but the subtitles encoding on screen is messed up
  2. I sent you the subs files

My comment was just an observation that could be related to the issue.

  1. When Just starts and subs do not work they are listed in the subs selection list and SELECTED by default
  2. When Just starts and the subs are listed, but NOT SELECTED in the list and I have to go select them manually, they show up when selected.

@courville
P.S. Regarding loading it will be nice if you send command to Just to load the first subtitle in the list. Generally a list is not necessary as most users will download only the subs they need. Plus if you have several subs the only way to load them is to use "Select subtitles on storage" to make NOVA rename the one you need to the name of the video.

Hope that helps.

@JJD2K
Copy link
Author

JJD2K commented Apr 28, 2024

@courville
Ok I tested many files and it seems that the encoding is wrong in 80% of the cases. I do not know why as those file work properly if JustPlayer is launched from MixPlorer.

@courville
Copy link
Contributor

@JJD2K perhaps the difference is that MixPlorer passes the file uri and nova provides the file as http streaming uri and in this case JustPlayer does not properly recognize the encoding. There is no reprocessing of the file by nova.

@JJD2K
Copy link
Author

JJD2K commented Apr 28, 2024

@courville
I don't understand the purpose of that. Cant' you just pass the uri too?
Did you manage to reproduce the other issue where the subs are listed and selected in Just and do not show up?

@courville
Copy link
Contributor

I tried but not that obvious. Will continue.

@JJD2K
Copy link
Author

JJD2K commented Apr 29, 2024

Is it a problem to pass the URI or do we have to notify @moneytoo about this issue?

@courville
Copy link
Contributor

No need. Let me progress on the issue.

courville added a commit to nova-video-player/aos-Video that referenced this issue May 8, 2024
add correct subtitles languages as names subs.name extra in the intent

nova-video-player/aos-AVP#1177
@courville
Copy link
Contributor

@JJD2K please try this release https://github.com/nova-video-player/aos-AVP/releases/tag/v6.2.72 and let me know if it works for you.

@JJD2K
Copy link
Author

JJD2K commented May 9, 2024

Hello @courville
Thank you for getting back to this.
I tested both your builds, unfortunately the issue is exactly the same as before.
Subtitle names are listed in Just, but they are not displayed.
You should be able to test this easily on your side too if you are using SMB shares - it is not something device specific.

courville added a commit to nova-video-player/aos-Video that referenced this issue May 9, 2024
…l players

See nova-video-player/aos-AVP#1177 (comment)

note that it may cause some encoding interpretation issues (not in french though)
@courville
Copy link
Contributor

@JJD2K indeed for some reason it does not pass the files.
I published a new release https://github.com/nova-video-player/aos-AVP/releases/tag/v6.2.72 (yes same tag) with some fixes and reverting to passing via http proxy the subs. I will display subs but with the encoding issue you noticed (it does not happen in french though).

@JJD2K
Copy link
Author

JJD2K commented May 9, 2024

@courville

Thank you, but seeing ??????????????????? instead of subtitles is as useless as no subtitles.
Subtitles work only in 5% of the cases now.
I can't believe that it is so hard to launch a process and set its working folder to the one of the video file.
It seems that there are many issues with the subtitles code. The issue that I reported before could be related to this problem too - on many subtitle files that are named as the video NOVA incorrectly displays some random short usually 3 letter text as subtitles name.
Currently I am looking at the info page of a file and the subs are listed as
EXTERNAL

  1. Ntb

When I open that video NOVA passes the same wrong name to Just player which also displays Ntb as the subtitles name.

I do not know how NOVA makes up those names, but they are random and not contained in the subs/video file name.

I do not think the encoding issue is related to any language - it is related to the file encoding. Probably the French files that you tested with match the Just player default encoding - try with the files that I sent you.

I really hope that you can fix these subtitles as I am using Just from MixPlorer now and it is playing everything that I throw at it flawlessly.

@courville
Copy link
Contributor

@JJD2K it works in many languages not yours (and I warned you about it): I prefer to have this instead of displaying nothing for now until I figure it out.
Please provide your external subtitle filename (only the name is enough) where the matching of nova is Ntb so that I can fix it (same rule as always: no sample, no complain).

@JJD2K
Copy link
Author

JJD2K commented May 10, 2024

@courville Hi
I sent you the file name and a screenshot. I've missed that NTb is last part of the file name, but it is not extension. Probably NOVA gets confused and interprets it as language identifier which is wrong as the file name ise XXXXXXXX-NTb.srt

The issue with subtitles is not language - it is encoding.
As I already wrote, the subtitles code is overly-complicated which probably leads to all these issues - probably there is a reason for it to be complicated (I know you support many protocols) , but the end result is not good.

I do not know how you have executed Just in your previous release, but I really think that it should be something very simple that you can easily test on your side. I am sorry if I have sounded annoying with my advices, but my aim was to help with suggestion.
You could just check the file path to detect that it is SMB share and call directly a separate function where to execute the external player and set its working directory to the path where the video is located. There was no need to change the rest of the subtitles code if you do not want to.

I am really disappointed that I can not use NOVA, but I appreciate the fact that you have spent time to try and fix this.
Thank you.

@courville
Copy link
Contributor

courville commented May 10, 2024 via email

@JJD2K
Copy link
Author

JJD2K commented May 10, 2024

@courville
Hi, yes I understand what NOVA does, but I do not think it is what common file explorers do.
I do not know how those file explorers are able to pass a video file on an SMB share to a video player that does not support SMB, but they definitely do not copy the files locally as I see the network activity. Plus even an 80GB file starts to play instantly and it would take time if they copied the file locally. Obviously there is no need to copy subtitle or other files locally.
The same way in which the player can play an SMB share it can load the SMB subs too.
That is why I guessed that they probably execute the players in a different way.
I do not know if you tried this code:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");

if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
{
    startActivity(intent);
}
else
{
    // if you reach this place, it means there is no any file 
    // explorer app installed on your device
}

@JJD2K
Copy link
Author

JJD2K commented May 11, 2024

@courville
I reported this issue at Justplayer: moneytoo/Player#586
unfortunately @moneytoo is not thrilled to fix it either - I am doomed ;)
Maybe he has a point that NOVA having access to the file should convert the stream to UTF8 as it may also contain BOM information and is easier to detect the encoding.

You already copy the file locally, could you please convert it to UTF8 before passing it as streamable url?
NOVA already loads Windows-1251 files properly so probably you already have the code for loading and then you just have to save it as UTF8 before passing it.

@ghost
Copy link

ghost commented May 11, 2024

While it is not a fix, I always just use this tool to batch merge my subtitles into their video files: https://github.com/iPzard/mkvtoolnix-batch-tool

@courville
Copy link
Contributor

@courville Hi, yes I understand what NOVA does, but I do not think it is what common file explorers do. I do not know how those file explorers are able to pass a video file on an SMB share to a video player that does not support SMB, but they definitely do not copy the files locally as I see the network activity. Plus even an 80GB file starts to play instantly and it would take time if they copied the file locally. Obviously there is no need to copy subtitle or other files locally. The same way in which the player can play an SMB share it can load the SMB subs too. That is why I guessed that they probably execute the players in a different way. I do not know if you tried this code:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");

if (intent.resolveActivityInfo(getPackageManager(), 0) != null)
{
    startActivity(intent);
}
else
{
    // if you reach this place, it means there is no any file 
    // explorer app installed on your device
}

To pass subtitle and video files to justplayer I use mxplayer API https://mx.j2inter.com/api which is not based on folder ACTION_VIEW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants