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

automatic skip only for Apps without Skip Button #208

Merged
merged 8 commits into from
Aug 31, 2024
Merged

Conversation

jumoog
Copy link
Member

@jumoog jumoog commented Jul 3, 2024

@jumoog jumoog requested a review from rlauuzo July 3, 2024 19:05
@JinglingB
Copy link

Eh. The auto skip option is the only way to have this plugin work with Jellyfin for Kodi.

@jumoog
Copy link
Member Author

jumoog commented Jul 3, 2024

Eh. The auto skip option is the only way to have this plugin work with Jellyfin for Kodi.

whats the ClientName? Already found it

@jumoog jumoog changed the title automatic skip only for the official Android TV App automatic skip only for Apps without Skip Button Jul 3, 2024
@JinglingB
Copy link

JinglingB commented Jul 3, 2024

Thanks. Sorry, I was modifying a plugin to dump the SessionInfo for something played by my Android TV device running Kodi.

I note that DeviceName is what I renamed my Kodi instance running on said device to via the Jellyfin admin web interface. Would looking at session.Client, which still reports "Kodi", be possible instead?

e: Thanks!

@AbandonedCart
Copy link
Member

AbandonedCart commented Jul 4, 2024

Why not future proof it? Android TV and Kodi can be your defaults and allow entry of user defined values. This also allows you to add new values in the future by simply updating a list.

@jumoog
Copy link
Member Author

jumoog commented Jul 4, 2024

Good idea. I would go one step further and let the user choose the client from his known clients list.

@jumoog
Copy link
Member Author

jumoog commented Jul 5, 2024

PoC:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drag and Drop Multiple Items</title>
    <style>
        .container {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 20px;
            margin-top: 50px;
        }
        ul {
            list-style-type: none;
            padding: 0;
            width: 200px;
            height: 300px;
            border: 1px solid #ccc;
            overflow-y: auto;
        }
        li {
            padding: 10px;
            cursor: pointer;
            border-bottom: 1px solid #ccc;
            user-select: none;
        }
        li:hover {
            background-color: #f0f0f0;
        }
        li.selected {
            background-color: #d0e0ff;
        }
    </style>
</head>
<body>

<div class="container">
    <ul id="leftList">
        <li draggable="true">Jellyfin Web</li>
        <li draggable="true">Jellyfin Android</li>
        <li draggable="true">Findroid</li>
        <li draggable="true">Jellyfin Media Player</li>
    </ul>
    <ul id="rightList">
        <li draggable="true">Android TV</li>
        <li draggable="true">Kodi</li>
    </ul>
</div>

<script>
    document.querySelectorAll('ul').forEach(list => {
        list.addEventListener('click', function(event) {
            if (event.target.tagName === 'LI') {
                event.target.classList.toggle('selected');
            }
        });

        list.addEventListener('dragstart', function(event) {
            if (event.target.tagName === 'LI') {
                const selectedItems = list.querySelectorAll('li.selected');
                if (!selectedItems.length) {
                    event.target.classList.add('selected');
                }
                event.dataTransfer.setData('text/plain', null);
            }
        });

        list.addEventListener('dragover', function(event) {
            event.preventDefault();
        });

        list.addEventListener('drop', function(event) {
            event.preventDefault();
            const selectedItems = document.querySelectorAll('.selected');
            selectedItems.forEach(item => {
                list.appendChild(item);
                item.classList.remove('selected');
            });
        });
    });

    document.querySelectorAll('li').forEach(item => {
        item.setAttribute('draggable', 'true');
    });
</script>

</body>
</html>

@AbandonedCart
Copy link
Member

AbandonedCart commented Jul 5, 2024

Findroid uses the plugin API and displays a native button. (To avoid confusion later)

@dredstone1
Copy link
Contributor

Add the option to auto skip when the player isn't currently active, for example when the user watch through pip.
Is that even possible to detect?

@AbandonedCart
Copy link
Member

It depends on the situation. In a native app, pip is handled by the app. On a website, it's handled by the browser. The browser would expose that information to JavaScript. The app may not.

https://stackoverflow.com/questions/61507068/checking-whether-or-not-a-video-is-picture-in-picture-mode

@dredstone1
Copy link
Contributor

The app version don't support pip, and from what you sent the web client can detect it, so it something that you can do?

@AbandonedCart
Copy link
Member

AbandonedCart commented Aug 26, 2024

The app version don't support pip, and from what you sent the web client can detect it, so it something that you can do?

#208 (this) is the PR for the feature. It’s still a draft. It will depend on whether jumoog wants to add Browser (PiP) as an option here or leave that to be a separate option.

@dredstone1
Copy link
Contributor

OK I will add issue. And maybe in the future I will code it myself

@AbandonedCart
Copy link
Member

OK I will add issue. And maybe in the future I will code it myself

The point of that was actually to be patient.

@@ -112,6 +112,12 @@ private void PlaybackTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
foreach (var session in _sessionManager.Sessions)
{
// only need for official Android TV App and jellyfin-kodi
if (session.Client != "Android TV" || session.Client != "Kodi")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s probably a good idea to auto-skip if injecting fails with an 'UnableToAddSkipButton' error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes thats a good idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be a log printed that that is why it’s automatically skipping. You know that’ll be at least one post in the issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did

@jumoog
Copy link
Member Author

jumoog commented Aug 31, 2024

Why not future proof it? Android TV and Kodi can be your defaults and allow entry of user defined values. This also allows you to add new values in the future by simply updating a list.

will do this in another PR. Im not in the mood for frontend today 😆

@jumoog jumoog marked this pull request as ready for review August 31, 2024 16:21
@AbandonedCart
Copy link
Member

The frontend will no doubt attract more posts about possible selections anyway, so keeping them separate will make it more manageable.

@jumoog jumoog merged commit 88003ed into master Aug 31, 2024
3 checks passed
@jumoog jumoog deleted the auto_skip_android_tv branch August 31, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants