diff options
author | Patiga <dev@patiga.eu> | 2022-06-28 12:11:17 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2024-11-14 10:20:12 -0600 |
commit | aaf4542e6208460c305db4be36b15dc832ddc95a (patch) | |
tree | ec7b60b0f0ea74e21403788e8345336bd0f3939b /main/src/ui/util | |
parent | 909f569318835d11703c49fba7dbe49996759f38 (diff) | |
download | dino-aaf4542e6208460c305db4be36b15dc832ddc95a.tar.gz dino-aaf4542e6208460c305db4be36b15dc832ddc95a.zip |
Implement XEP-0447: Stateless file sharing
Diffstat (limited to 'main/src/ui/util')
-rw-r--r-- | main/src/ui/util/file_metadata_providers.vala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/ui/util/file_metadata_providers.vala b/main/src/ui/util/file_metadata_providers.vala new file mode 100644 index 00000000..9e8d9640 --- /dev/null +++ b/main/src/ui/util/file_metadata_providers.vala @@ -0,0 +1,27 @@ +using Dino.Entities; +using Xmpp; +using Xmpp.Xep; +using Gtk; + +namespace Dino.Ui.Util { + +public class AudioVideoFileMetadataProvider: Dino.FileMetadataProvider, Object { + public bool supports_file(File file) { + string? mime_type = file.query_info("*", FileQueryInfoFlags.NONE).get_content_type(); + if (mime_type == null) { + return false; + } + return mime_type.has_prefix("audio") || mime_type.has_prefix("video"); + } + + public async void fill_metadata(File file, Xep.FileMetadataElement.FileMetadata metadata) { + MediaFile media = MediaFile.for_file(file); + media.notify["prepared"].connect((object, pspec) => { + Idle.add(fill_metadata.callback); + }); + yield; + metadata.length = media.duration / 1000; + } +} + +}
\ No newline at end of file |