[API][Android] API feature proposal and wishlist.

Discussion in 'General Development' started by andy22, May 23, 2022.

  1. andy22

    andy22 Active Member

    The internal "com.android.gallery3d" player has no official Android API or documentation, which makes it very hard to implement most of the standard features users expect from a working media app.

    Most of the needed features already exist inside the "MovieActivity" or "ZDMCActivity", yet those only accept a very limited number of extra input data and don't hand any setResult() fields back to the calling Activity. This is the main reason why external apps cant properly get the playback status and playback position, to use in there own resume and watched status handling.

    I don't see why Zidoo needs to reinvent the wheel, since Jellyfin/Emby already have support for the MX Player and VLC API, so all we need to-do is add those basic API functions to the internal player.

    Here are the MX Player, VLC API documentation which we should try to follow as close as possible, so no extra pull request are needed to get basic stuff working for the Zidoo player:
    https://sites.google.com/site/mxvpen/api
    https://wiki.videolan.org/Android_Player_Intents/

    Here is a commit example on how "Just Player" got basic support working for Jellyfin, with just a trivial change in there code.
    https://github.com/moneytoo/Player/commit/f8e646da3d4befe2fad71a684e73cfc074fce68d

    API use Proposal/Example (what we want to use in the calling Activity)
    Code:
    Uri uri = Uri.parse("file:///storage/emulated/0/Movies/KUNG FURY Official Movie.mp4");
    Intent zidooIntent = new Intent(Intent.ACTION_VIEW);
    external.setPackage("com.android.gallery3d");
    external.setComponent(new ComponentName("com.android.gallery3d", "com.android.gallery3d.app.MovieActivity")); # or a specific "VideoActivityAPI" for external use cases
    zidooIntent.setDataAndTypeAndNormalize(uri, "video/*");
    
    zidooIntent.putExtra("title", "Kung Fury");
    zidooIntent.putExtra("from_start", false);
    zidooIntent.putExtra("position", (int) 90000l);
    
    # on subtitle handling MX player and VLC differ
    zidooIntent.putExtra("subtitles_location", "/sdcard/Movies/Fifty-Fifty.srt");
    zidooIntent.putExtra("subs", [subs]); # Parcelable array (android.net.Uri[])
    
    # better subtitle search results, NOTE: Jellyfin only sets a "stream.mkv" by default
    zidooIntent.putExtra("filename", filename);
    zidooIntent.putExtra("size", filesize);
    zidooIntent.putExtra("hash.opensubtitles", filehash); # see: https://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes
    
    # enable result return handling
    zidooIntent.putExtra("return_result", true);
    int requestCode = 1;
    startActivityForResult(zidooIntent, requestCode);
    
    The player should than support returning a result on Finish(), either the mxtech or vlc identifier can be used. At least a "position" field and a returncode should be set.
    Code:
    Intent result_intent = new Intent("com.mxtech.intent.result.VIEW");
    result_intent.putExtra("end_by", playbackFinished ? "playback_completion" : "user");
    result_intent.putExtra("duration", (int) player.getDuration()); # Duration of last played video in milliseconds.
    result_intent.putExtra("position", (int) player.getCurrentPosition()); # Last playback position in milliseconds.
    
    setResult(Activity.RESULT_OK, result_intent);
    super.finish();
    
    Some extra audio, subtitle handling if Zidoo wants to stand out! The reason is that external apps have there own per user audio/subtitle handling, settings.
    This is helpful for multi-user environments or multilingual households (Anime Kid).

    API Wishlist
    Code:
    zidooIntent.putExtra("audio_languages", ["jpn","kor","chz","eng"]); # array of iso codes of preferred audio languages, sorted by priority
    zidooIntent.putExtra("subtitle_languages", ["eng","spa"]); # subtitle preferences
    zidooIntent.putExtra("audio_flags", "default"); # prefer the default flagged audio track that also matches with audio_languages
    zidooIntent.putExtra("subtitle_flags", "forced"); # prefer the forced subtitle track if it matches the subtitle_languages
    zidooIntent.putExtra("same_language_subtitle_track", true); # display subtitle track even if it matches the audio track language
    zidooIntent.putExtra("subtitle_shd", true); # prefer "shd" named tracks for hearing impaired
    zidooIntent.putExtra("subtitle_track_filter", ["signs","songs","shd","cc"]); # list of trackname filter words to ignore, avoids using "sign/songs" subs or "shd" even if flagged forced/default
    
     
    Last edited: May 24, 2022
    Sledgehamma likes this.
  2. andy22

    andy22 Active Member

    Got a first reply from the Devs, so fingers crossed.
    Maybe make your voices heard, since in my opinion Zidoo internal player should have a premium API. So end-users can freely choose between HT/Jellyfin/Emby/ZDMC without any issues/limitations. Switching to HT 4.0 will always add extra friction and a learning curve, while potentially missing many features new users are expecting from a modern media center.
    So why not spend some minor Dev time to develop/improve a Android API, which can be a actual selling point for potential costumers.

    As example i could not get any reliable information on what HT actually is and can and cant do and if the JellyfinTv/Emby/Plex apps work or if ZDMC has any major drawbacks. So if we can change this and just state "all works" this would come a long way.
     
    Last edited: May 23, 2022
    Purple and Sledgehamma like this.
  3. Sledgehamma

    Sledgehamma Well-Known Member

    This alone would make Zidoo stand out even more in contrast to other RTD based players and I think they will sell more players when marketing this feature.
    Also, Zidoo players will be mentioned on Jellyfin and Emby forums, basically free advertising ;)

    I only knew Jellyfin existed because Infuse on Apple TV added support for it and I looked into it.

    Why would the API need to include audio and subtitle streams?
     
  4. andy22

    andy22 Active Member

    Yeah basically there are two main camps on HTPC/Media Players, the first used Kodi for the last 10 years and swear by it. This crowd can somewhat easily adapt to HT 4.0 if needed or use ZDMC with the know issues.
    Than we have the Plex/Emby/Jellyfin/(Infuse) crowd that fundamentally manage there media differently and have a ecosystem with multiple client devices.
    This group wont be happy with HT 4.0 or base ZDMC, since that's not what they are used too. Yet there is no real reason why the second group cant be happy, since the native AndroidTV apps run just fine on zidoo's Android 9 OS from what i have tested.
     
  5. Black-Angel28

    Black-Angel28 Member

    Regardless of what happens, I would just like to say thank you for taking on this matter. For me, HT is not a real alternative to ZDMC due to some errors and limitations. With ZDMC, however, it bothers me immensely that the automatic viewing status is not currently properly supported by the native player.

    Small note: With zdmc I noticed that various skins (e.g. Aeon Tajo) which work without problems with the normal Kodi do not start. The installation works without errors, only the start and use does not.
     
  6. sat4all

    sat4all New Member

    I would just like to say thank you for taking on this matter.
     
  7. jh82

    jh82 New Member

    I too would like to see this extra functionality added. I have 2 Zidoo boxes while they are good playback devices, I feel they are extremely limited. Being able to get full use of other apps like Plex, Emby, ZDMC, etc would make me feel a lot better about my purchases and make it more likely that I would recommend these boxes to other users.
     
  8. andy22

    andy22 Active Member

    Quick update:

    I'm working on the JellyfinTV app "Zidoo Edition" and got the basic stuff working, so playback with internal VS10 player from a smb share works.
    I also managed to add basic support for the existing http api, so seek/resume position and watched detection works.

    I did run into a small issue, since the JellyfinTV app has no option class for a text input field, so i cant just add "smb_user", "smb_password" settings to the UI.
    Not sure how to handle this atm, so either "guest" access has to work or i need to find some other quick hack/workaround.

    PS: I still have no clue if/when Zidoo devs might add a real Android API, since i will never get the current http based stuff merged upstream. No other player is implemented via a http api.
     
    Sledgehamma likes this.
  9. andy22

    andy22 Active Member

    Just noticed that we can actually just add user/pw via a normal SMB uri on the server network path settings field, which i can than easily parse on the client app.
    Example:
    Code:
    smb://username:password@server/share
    
     
    Sledgehamma likes this.
  10. Sledgehamma

    Sledgehamma Well-Known Member

    Sweet! If you need help testing let me know.
     
  11. mattmarsden

    mattmarsden Active Member

    So to clarify, we can use Jellyfin via http streaming and get 2 way watched status with the Zidoo player?
     
  12. andy22

    andy22 Active Member

    Not sure what you mean?

    I'm adding support for the internal VS10 player to the JellyfinTV app and use the http/api to get the playback positions, so the app can correctly mark stuff watched or will get the resume times.
    The internal player seems to always broadcast the playback status to the zidoo bookmarks api, which is used by HT 4.0, if thats what you mean?

    I'm not explicitly syncing any Jellyfin server data to the HT 4.0 stuff, i don't plan to use HT at all.

    I also had major hickups/bugs using the internal player via default jellyfin http streams, even tried a dav server.
    Given those http/stream issues, the expected mode for the zidoo player in jellyfin will be via smb or nfs shares.
    Those can be setup via the "network paths" substitution setting on the server on a per library basis.
     
  13. mattmarsden

    mattmarsden Active Member

    Ok that sound amazing and exactly what I want. If I watched a bit of something on another Jellyfin player would it resume to that point last watched on the Zidoo?
     
  14. andy22

    andy22 Active Member

    Yes the positions are stored on a per user basis on the server. The goal is to get all the basic stuff working, so our "zidoo edition" works the same as the native jellyfin player.

    PS: I'm not sure how much time i want to invest to get the per user audio/subtitle settings working, but its possible to-do. In contrast to zidoo HT, jellyfin allows each user to have there own audio/subtitle settings/preferences.
     
  15. mattmarsden

    mattmarsden Active Member

    Yep subtitles/audio not an issue for me but resume positions would be amazing
     
  16. Cyclone99

    Cyclone99 New Member

    Will playback over an NFS share work also, or just SMB?
     
  17. andy22

    andy22 Active Member

    Nfs will be supported, but i need to test this later.
    Atm i'm concentrating on getting smb working, since i don't have a nfs share atm and the player has some weird "nfs_root" parameter logic that i need to understand.
     
  18. mattmarsden

    mattmarsden Active Member

    Let me know if I can help testing
     
  19. andy22

    andy22 Active Member

    Thanks looking good so far, smb + username/password via simple "smb://" URI works fine and is easy to use in the server settings.
    Also has the advantage that the server admin can set those-up without the client/user needing to know them.

    I still need to make the playback position and seek/resume behavior more robust. I have to poll the Zidoo HTTP api in separate threads which is a pain to setup/work with, yet works fine so far.
    I also need to add more checks and warning popups, so the user understands that you need to setup Jellyfin server network paths correctly.

    Other than that looks good, but i still want to try solve this issue before i release a beta: https://github.com/jellyfin/jellyfin-androidtv/issues/1774
     
  20. mattmarsden

    mattmarsden Active Member

    Awesome, sounds great. Can the Android Jellyfin app be skinned and would that help with the problem?
     

Share This Page