is QtMultimedia available to use in go?

207 views
Skip to first unread message

Marc Poch

unread,
Mar 11, 2015, 7:02:17 AM3/11/15
to go-...@googlegroups.com
Hello folks,

I'm trying to play an audio file in my go program. Because it already uses go-qml to display user interface I thought I could use QtMultimedia module.

But when I "import QtMultimedia 5.0" on the qml file, I get 'module "QtMultimedia" is not installed' error. Is this an error of my golang installation or it is because QtMultimedia module is not available in go?

Thanks

Marc Poch

unread,
Mar 11, 2015, 8:31:23 AM3/11/15
to go-...@googlegroups.com
Hello, it's me again.

I would like to reformulate my question.

If I give a go file:
package main

import (
   
"fmt"
   
"os"
   
"gopkg.in/qml.v1"
)

func main
() {
   
if err := qml.Run(run); err != nil {
        fmt
.Fprintf(os.Stderr, "error: %v\n", err)
        os
.Exit(1)
   
}  
}

func run
() error {
    engine
:= qml.NewEngine()
    component
, err := engine.LoadFile("main.qml")
   
if err != nil {
       
return err
   
}  

    window
:= component.CreateWindow(nil)

    window
.Show()
    window
.Wait()

   
return nil
}

And a qml file:
import QtQuick 2.0
import QtMultimedia 5.0

Text {
    text
: "Click Me!";
    font
.pointSize: 24;
    width
: 150; height: 50;

 
Audio {
        id
: playMusic
        source
: "music.wav"
   
}  
   
MouseArea {
        id
: playArea
        anchors
.fill: parent
        onPressed
:  { playMusic.play() }
   
}  
}

compile with: GOBIN=. go install main.go

Does It works for you? If so, I must check my qt5 installation or my golang installation if not, maybe it means qtmultimedia is not available to use in golang.

Thanks in advance.

Takashi Oguma

unread,
Mar 12, 2015, 8:18:33 AM3/12/15
to Marc Poch, go-...@googlegroups.com
On my Mac, your qml file and go file worked expectedly. (I needed to make up "music.wav" but could played the audio)
I could create a binary by the `go install` command.

My environment:
Mac OS X (10.9.5)
go version: 1.4.1
Qt5 version: 5.4.0 (installed using brew)


--
You received this message because you are subscribed to the Google Groups "go-qml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-qml+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Takashi OGUMA  小熊 崇

Marc Poch

unread,
Mar 12, 2015, 10:02:48 AM3/12/15
to Takashi Oguma, go-...@googlegroups.com
Hello,

 Thanks for your time, now I know it must work. I will check my system and qt installation to solve the problem.

My environment:
GNU/Linux Gentoo (64bits)
go version: 1.4.1
qt5 version: 5.4.1
 
 Currently I'm installing qt-creator to test it with C++ and discover where my problem is.

 Thanks.

--
            Marc
              マルク
                  www.crimpa.net

Marc Poch

unread,
Mar 12, 2015, 8:04:48 PM3/12/15
to Takashi Oguma, go-...@googlegroups.com
I just want to left the solution of my problem here, maybe it is useful to someone in the future.

My problem does not was related with go nor QML. It was because my system didn't have the plugins of gstreamer version 0.10 version does to play audio.

I'm glad I solved the problem, thanks.
--
            Marc
              マルク
                  www.crimpa.net
Reply all
Reply to author
Forward
0 new messages