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

Play video from folder #122

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

peteruithoven
Copy link
Contributor

@peteruithoven peteruithoven commented Feb 26, 2019

It's quite common that video torrents are folders with the video file. I'm trying to make it easier to play that video from Torrential without having to deal with files.
Fixes: #107

An alternative approach might be to have an easier / quicker way to open a specific file in a folder, for example by showing the file tree in a menu somewhere.

ToDo:

  • Determine if torrent is playable
  • Add play video option to context menu
  • Open video in default video application

@peteruithoven peteruithoven changed the title Play from folder [WIP] Play from folder Feb 26, 2019
@peteruithoven peteruithoven changed the title [WIP] Play from folder Play from folder Feb 26, 2019
@peteruithoven peteruithoven marked this pull request as ready for review February 26, 2019 14:48
@peteruithoven peteruithoven changed the title Play from folder Play video from folder Feb 26, 2019
@peteruithoven
Copy link
Contributor Author

Looking through the AppInfo API I noticed there is a launch_default_for_uri function which seems like a much easier way to do things. It removes the need for the content type guess and the need to create a uri list for example.

Before

private bool open_file (string file_path) {
    bool certain = false;
    var content_type = ContentType.guess (file_path, null, out certain);
    var appinfo = AppInfo.get_default_for_type (content_type, true);
    if (appinfo != null) {
        var file = File.new_for_path (file_path);
        if (file.query_exists ()) {
            var file_list = new List<string> ();
            file_list.append (file.get_uri ());
            try {
                appinfo.launch_uris (file_list, null);
                return true;
            } catch (Error e) {
                warning ("Unable to launch default handler for %s", content_type);
            }
        }
    }
    return false;
}

After

private bool open_file (string file_path) {
    var file = File.new_for_path (file_path);
    if (file.query_exists ()) {
        try {
            AppInfo.launch_default_for_uri (file.get_uri (), null);
            return true;
        } catch (Error e) {
            warning ("Unable to launch default handler for %s", file_path);
        }
    }
    return false;
}

Should I simplify the open_file method or am I missing something that the current approach handles better?

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.

1 participant