mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 08:58:37 +00:00
multimedia: add qt6 version of the example
This commit is contained in:
parent
3c8c85a43e
commit
c69b704a61
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,6 +29,7 @@ examples/libraries/extras-scintillaedit/extras-scintillaedit
|
||||
examples/libraries/qt-multimedia/qt-multimedia
|
||||
examples/libraries/qt-network/qt-network
|
||||
examples/libraries/qt-printsupport/qt-printsupport
|
||||
examples/libraries/qt6-multimedia/qt6-multimedia
|
||||
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla
|
||||
|
||||
# android temporary build files
|
||||
|
3
examples/libraries/qt6-multimedia/README.md
Normal file
3
examples/libraries/qt6-multimedia/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
The audio file `pixabay-public-domain-strong-hit-36455.mp3` in this directory was sourced from: https://pixabay.com/sound-effects/strong-hit-36455/
|
||||
|
||||
It was placed into the public domain by the author @axilirate .
|
41
examples/libraries/qt6-multimedia/main.go
Normal file
41
examples/libraries/qt6-multimedia/main.go
Normal file
@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
qt "github.com/mappu/miqt/qt6"
|
||||
"github.com/mappu/miqt/qt6/multimedia"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
qt.NewQApplication(os.Args)
|
||||
|
||||
srcFile, err := filepath.Abs("pixabay-public-domain-strong-hit-36455.mp3")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
player := multimedia.NewQMediaPlayer()
|
||||
output := multimedia.NewQAudioOutput()
|
||||
|
||||
player.SetAudioOutput(output)
|
||||
player.SetSource(qt.QUrl_FromLocalFile(srcFile))
|
||||
output.SetVolume(50)
|
||||
player.OnPlaybackStateChanged(func(s multimedia.QMediaPlayer__PlaybackState) {
|
||||
|
||||
log.Printf("- Playback state: %v", s)
|
||||
|
||||
if s == multimedia.QMediaPlayer__StoppedState {
|
||||
log.Printf("Playback complete.")
|
||||
qt.QCoreApplication_Exit()
|
||||
}
|
||||
})
|
||||
|
||||
log.Printf("Playback starting...")
|
||||
player.Play()
|
||||
|
||||
qt.QApplication_Exec()
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user