Skip to content

Commit

Permalink
Merge pull request #75 from mappu/fix-qt6-multimedia
Browse files Browse the repository at this point in the history
Qt6Multimedia: Fix compilation, add example
  • Loading branch information
mappu authored Nov 12, 2024
2 parents 0b16793 + c69b704 commit 4669ec0
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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
Expand Down
4 changes: 4 additions & 0 deletions cmd/genbindings/config-allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ func AllowMethod(className string, mm CppMethod) error {
return ErrTooComplex // Present in Qt 5.15 and 6.4, missing in Qt 6.7
}

if className == "QWaveDecoder" && mm.MethodName == "setIODevice" {
return ErrTooComplex // Qt 6: Present in header, but no-op method was not included in compiled library
}

return nil // OK, allow
}

Expand Down
3 changes: 3 additions & 0 deletions examples/libraries/qt6-multimedia/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 41 additions & 0 deletions examples/libraries/qt6-multimedia/main.go
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 0 additions & 4 deletions qt6/multimedia/gen_qwavedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ long long QWaveDecoder_Pos(const QWaveDecoder* self) {
return static_cast<long long>(_ret);
}

void QWaveDecoder_SetIODevice(QWaveDecoder* self, QIODevice* device) {
self->setIODevice(device);
}

long long QWaveDecoder_Size(const QWaveDecoder* self) {
qint64 _ret = self->size();
return static_cast<long long>(_ret);
Expand Down
4 changes: 0 additions & 4 deletions qt6/multimedia/gen_qwavedecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ func (this *QWaveDecoder) Pos() int64 {
return (int64)(C.QWaveDecoder_Pos(this.h))
}

func (this *QWaveDecoder) SetIODevice(device *qt6.QIODevice) {
C.QWaveDecoder_SetIODevice(this.h, (*C.QIODevice)(device.UnsafePointer()))
}

func (this *QWaveDecoder) Size() int64 {
return (int64)(C.QWaveDecoder_Size(this.h))
}
Expand Down
1 change: 0 additions & 1 deletion qt6/multimedia/gen_qwavedecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ bool QWaveDecoder_Open(QWaveDecoder* self, int mode);
void QWaveDecoder_Close(QWaveDecoder* self);
bool QWaveDecoder_Seek(QWaveDecoder* self, long long pos);
long long QWaveDecoder_Pos(const QWaveDecoder* self);
void QWaveDecoder_SetIODevice(QWaveDecoder* self, QIODevice* device);
long long QWaveDecoder_Size(const QWaveDecoder* self);
bool QWaveDecoder_IsSequential(const QWaveDecoder* self);
long long QWaveDecoder_BytesAvailable(const QWaveDecoder* self);
Expand Down

0 comments on commit 4669ec0

Please sign in to comment.