Merge pull request #75 from mappu/fix-qt6-multimedia

Qt6Multimedia: Fix compilation, add example
This commit is contained in:
mappu 2024-11-12 18:25:57 +13:00 committed by GitHub
commit 4669ec0632
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 49 additions and 9 deletions

1
.gitignore vendored
View File

@ -31,6 +31,7 @@ examples/libraries/extras-scintillaedit/extras-scintillaedit
examples/libraries/qt-multimedia/qt-multimedia 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/qt6-multimedia/qt6-multimedia
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla
# android temporary build files # android temporary build files

View File

@ -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 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 return nil // OK, allow
} }

View 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 .

View 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()
}

View File

@ -79,10 +79,6 @@ long long QWaveDecoder_Pos(const QWaveDecoder* self) {
return static_cast<long long>(_ret); return static_cast<long long>(_ret);
} }
void QWaveDecoder_SetIODevice(QWaveDecoder* self, QIODevice* device) {
self->setIODevice(device);
}
long long QWaveDecoder_Size(const QWaveDecoder* self) { long long QWaveDecoder_Size(const QWaveDecoder* self) {
qint64 _ret = self->size(); qint64 _ret = self->size();
return static_cast<long long>(_ret); return static_cast<long long>(_ret);

View File

@ -123,10 +123,6 @@ func (this *QWaveDecoder) Pos() int64 {
return (int64)(C.QWaveDecoder_Pos(this.h)) 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 { func (this *QWaveDecoder) Size() int64 {
return (int64)(C.QWaveDecoder_Size(this.h)) return (int64)(C.QWaveDecoder_Size(this.h))
} }

View File

@ -42,7 +42,6 @@ bool QWaveDecoder_Open(QWaveDecoder* self, int mode);
void QWaveDecoder_Close(QWaveDecoder* self); void QWaveDecoder_Close(QWaveDecoder* self);
bool QWaveDecoder_Seek(QWaveDecoder* self, long long pos); bool QWaveDecoder_Seek(QWaveDecoder* self, long long pos);
long long QWaveDecoder_Pos(const QWaveDecoder* self); long long QWaveDecoder_Pos(const QWaveDecoder* self);
void QWaveDecoder_SetIODevice(QWaveDecoder* self, QIODevice* device);
long long QWaveDecoder_Size(const QWaveDecoder* self); long long QWaveDecoder_Size(const QWaveDecoder* self);
bool QWaveDecoder_IsSequential(const QWaveDecoder* self); bool QWaveDecoder_IsSequential(const QWaveDecoder* self);
long long QWaveDecoder_BytesAvailable(const QWaveDecoder* self); long long QWaveDecoder_BytesAvailable(const QWaveDecoder* self);