Created
May 22, 2024 23:40
-
-
Save pojntfx/5286e2ecf076925fcfcc5ce32b4405e4 to your computer and use it in GitHub Desktop.
Play a video from hTorrent with GJS and gtk4paintablesink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Gtk 4.0; | |
| using Adw 1; | |
| Adw.Clamp page { | |
| maximum-size: 1920; | |
| Box { | |
| orientation: vertical; | |
| Picture video {} | |
| Button regular { | |
| name: "regular"; | |
| label: _("Pause"); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Gtk from "gi://Gtk"; | |
| import Gst from "gi://Gst"; | |
| const regular = workbench.builder.get_object("regular"); | |
| const videoPicture = workbench.builder.get_object("video"); | |
| const videoSink = Gst.ElementFactory.make("gtk4paintablesink", "video_sink"); | |
| const pipeline = Gst.parse_launch( | |
| `playbin uri=http://admin:myapipassword@localhost:1337/stream?magnet=magnet%3A%3Fxt%3Durn%3Abtih%3A08ada5a7a6183aae1e09d831df6748d566095a10%26dn%3DSintel%26tr%3Dudp%253A%252F%252Fexplodie.org%253A6969%26tr%3Dudp%253A%252F%252Ftracker.coppersurfer.tk%253A6969%26tr%3Dudp%253A%252F%252Ftracker.empire-js.us%253A1337%26tr%3Dudp%253A%252F%252Ftracker.leechers-paradise.org%253A6969%26tr%3Dudp%253A%252F%252Ftracker.opentrackr.org%253A1337%26tr%3Dwss%253A%252F%252Ftracker.btorrent.xyz%26tr%3Dwss%253A%252F%252Ftracker.fastcast.nz%26tr%3Dwss%253A%252F%252Ftracker.openwebtorrent.com%26ws%3Dhttps%253A%252F%252Fwebtorrent.io%252Ftorrents%252F%26xs%3Dhttps%253A%252F%252Fwebtorrent.io%252Ftorrents%252Fsintel.torrent&path=Sintel%2FSintel.mp4`, | |
| ); | |
| pipeline.set_property("video-sink", videoSink); | |
| videoPicture.set_paintable(videoSink.paintable); | |
| pipeline.set_state(Gst.State.PLAYING); | |
| regular.connect("clicked", () => pipeline.set_state(Gst.State.PAUSED)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment