mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
qmultimedia: add example
This commit is contained in:
parent
3d2a20172e
commit
7253798b9b
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,6 +26,7 @@ examples/mdoutliner/mdoutliner
|
|||||||
examples/windowsmanifest/windowsmanifest
|
examples/windowsmanifest/windowsmanifest
|
||||||
examples/uidesigner/uidesigner
|
examples/uidesigner/uidesigner
|
||||||
examples/libraries/extras-scintillaedit/extras-scintillaedit
|
examples/libraries/extras-scintillaedit/extras-scintillaedit
|
||||||
|
examples/libraries/qt-multimedia/qt-multimedia
|
||||||
examples/libraries/qt-network/qt-network
|
examples/libraries/qt-network/qt-network
|
||||||
examples/libraries/qt-printsupport/qt-printsupport
|
examples/libraries/qt-printsupport/qt-printsupport
|
||||||
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla
|
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla
|
||||||
|
3
examples/libraries/qt-multimedia/README.md
Normal file
3
examples/libraries/qt-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 .
|
40
examples/libraries/qt-multimedia/main.go
Normal file
40
examples/libraries/qt-multimedia/main.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/mappu/miqt/qt"
|
||||||
|
"github.com/mappu/miqt/qt/multimedia"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
qt.NewQApplication(os.Args)
|
||||||
|
|
||||||
|
srcFile, err := filepath.Abs("pixabay-public-domain-strong-hit-36455.mp3")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
content := multimedia.NewQMediaContent2(qt.QUrl_FromLocalFile(srcFile))
|
||||||
|
|
||||||
|
player := multimedia.NewQMediaPlayer()
|
||||||
|
player.SetMedia(content)
|
||||||
|
player.SetVolume(50)
|
||||||
|
player.OnStateChanged(func(s multimedia.QMediaPlayer__State) {
|
||||||
|
|
||||||
|
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