PDA

View Full Version : Not able to play ogg files on Mac using QMediaPlayer.



gova2009
19th May 2016, 13:24
I want to play ogg file on mac using Qt 5.6. Below is the application code I wrote to test.


#include "mainwindow.h"

Widget::Widget(QWidget *parent)
: QWidget(parent)
{
m_player = new QMediaPlayer(this);
connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatu s)), this, SLOT(onMediaStatusChanged()));
connect(m_player, SIGNAL(positionChanged(qint64)), this, SLOT(onProgressed(qint64)));
m_player->setMedia(QMediaContent(QUrl::fromLocalFile("/Users/koragg/Downloads/IntheMoon.ogg")));
m_player->play();
}

Widget::~Widget()
{

}

void Widget::onProgressed(qint64 pos)
{
qDebug()<<"Position is:"<<pos;
}

void Widget::onMediaStatusChanged()
{
qDebug()<<"Media Status Changed:" << m_player->mediaStatus() << " " << m_player->error();
}



Here is the output I am getting.

Position is: 0
Media Status Changed: QMediaPlayer::LoadingMedia QMediaPlayer::NoError
Media Status Changed: QMediaPlayer::InvalidMedia QMediaPlayer::FormatError

Same code is working fine on windows (except the file path of course) for all formats(wav, aiff).
Other formats are being played on mac also. Problem is only with the ogg format. Can somebody help me with that?