Setting a new media file for Media Controls does not update the timeline

Here my simple example on Nim:

import gintro/[gtk4, gobject, gio]
import std/with, os

type
  ControlWithMediaFile = tuple
    file: MediaFile
    controls: MediaControls

proc entryChanged(self: EntryBuffer, position: int, chars: string, nChars: int, media: ControlWithMediaFile) = 
  echo self.text
  if os.fileExists(self.text):
    media.file.clear
    media.file.setFilename self.text

proc appActivate(app: Application) =
  let 
    window = newApplicationWindow(app)
    mainBox = newBox(Orientation.vertical, 3)
    mediaFile = newMediaFileForFilename("5minAudio.mp3")
    mediaControls = newMediaControls(mediaFile)
    mediaPathEntry = newEntry()

  mediaPathEntry.placeholderText = "Enter music filename"
  mediaPathEntry.buffer.connect("inserted_text", entryChanged, (mediaFile, mediaControls))

  with mainBox:
    append mediaPathEntry
    append mediaControls

  with window:
    child = mainBox
    title = "MediaControls"
    defaultSize = (250, 0)
    show

proc main =
  let app = newApplication("org.gtk.example")
  connect(app, "activate", appActivate)
  discard run(app)

main()

When I change the Media File for Media Controls, the timeline parameters are not updated in Media Controls.

It should be fixed in GTK 4.2.2/4.3: https://gitlab.gnome.org/GNOME/gtk/-/issues/3914

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.