slint/examples/gstreamer-player/scene.slint
Be a1378373ae
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
CI / python_test (macos-14) (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, --exclude bevy-example, windows-2022, 1.85) (push) Blocked by required conditions
autofix.ci / lint_typecheck (push) Waiting to run
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / build_and_test (--exclude bevy-example, ubuntu-22.04, 1.85) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.85) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
GStreamer example: set window to dimensions of example video
2025-07-29 20:33:39 +02:00

80 lines
2.3 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { VerticalBox, Palette } from "std-widgets.slint";
export component App inherits Window {
in property <image> video-frame <=> image.source;
in property <int> buffering-percent;
in property <bool> playing;
pure callback toggle-pause-play();
preferred-width: 854px;
preferred-height: 480px;
min-width: 854px;
min-height: 480px;
title: "Slint GStreamer Video Playback Example";
background: #000000;
icon: @image-url("../../logo/slint-logo-small-light.png");
states [
buffering when buffering-percent < 100: {
controls.opacity: 0;
buffering-indicator.opacity: 1;
// Without this, the last percentage shown will be < 100%
out {
animate buffering-indicator.opacity {
duration: 100ms;
}
}
}
shown when (!playing || controls-area.has-hover) && buffering-percent == 100: {
controls.opacity: 1;
buffering-indicator.opacity: 0;
in {
animate controls.opacity {
duration: 500ms;
}
}
}
hidden when playing && buffering-percent == 100: {
controls.opacity: 0;
buffering-indicator.opacity: 0;
}
]
VerticalBox {
image := Image {}
}
area := TouchArea {
width: 100%;
height: 100%;
clicked => {
root.toggle-pause-play();
}
buffering-indicator := Text {
text: "Buffering... \{buffering-percent}%";
}
controls := Rectangle {
width: 50%;
height: self.preferred-height;
y: root.height - self.height - 40px;
border-radius: 4px;
background: Palette.color-scheme == ColorScheme.dark ? #3737378c : #ffffff82;
play-pause := Image {
width: 64px;
height: 64px;
source: root.playing ? @image-url("pause.svg") : @image-url("play.svg");
}
controls-area := TouchArea {
clicked => {
root.toggle-pause-play();
}
}
}
}
}