Qsoundeffect qaudio error decoding source

Нету звука в Qt 5.5.7 Добрый день!Столкнулся с такой проблемой: необходимо добавить в приложение звук. Пробовал через QSound.Постоянно получаю ошибку QSoundEffect(pulseaudio): Error decoding source!Через Qmedia также не работает. Пользуюсь ubuntu 16.04.Файлы в которых добавляется музыка,ниже Рекомендуем хостинг TIMEWEB Добрый день. Возможен вариант, что файл, который Вы подготовили не поддерживается корректно. Для pulseaudio он просто […]

Содержание

  1. Нету звука в Qt 5.5.7
  2. QSoundEffect(pulseaudio): Error decoding sourc
  3. 2 Answers
  4. Qsoundeffect qaudio error decoding source
  5. Qsoundeffect qaudio error decoding source

Нету звука в Qt 5.5.7

Добрый день!Столкнулся с такой проблемой: необходимо добавить в приложение звук. Пробовал через QSound.Постоянно получаю ошибку QSoundEffect(pulseaudio): Error decoding source!Через Qmedia также не работает. Пользуюсь ubuntu 16.04.Файлы в которых добавляется музыка,ниже

Рекомендуем хостинг TIMEWEB

Добрый день.
Возможен вариант, что файл, который Вы подготовили не поддерживается корректно.
Для pulseaudio он просто считается битым.

Попробуйте для начала тоже самое сделать с помощью другого аудиофайла. Например, взятого из какого-нибудь аудиоальбома. Проверьте несколько других файлов.

  • Евгений Легоцкой → Леха Завистович
  • #
  • 9 октября 2016 г. 20:23
  • Ответ был помечен как решение.

Оки. Давайте так сделаем. Во вложении я добавил гарантированно рабочий пример с QSound и аудио файлом.
Но. Я использую Qt 5.7 и проверял под Ubuntu 16.04.

Поэтому если у Вас всё-таки не заработает мой вариант запуска QSound, то рекомендую:

1. обновить Qt,
2. прошерстить аудиофайлы, которые используете, есть вероятность, что всё-таки что-то не то пытаетесь скормить QSound.
3. Ну и совсем крайний вариант, это у Вас проблемы с самим pulseaudio и стоит покопаться в памяти на предмет того, какие манипуляции производили с аудиосистемой Ubuntu, что угробили её.

Если заработает, то посмотрите, чем мой вариант отличается от вашего.
Возможно, что не всё подключено в Pro файле, обратите на него внимание.

Источник

QSoundEffect(pulseaudio): Error decoding sourc

I am working on an App that should include sounds but I cannot get it to work. Here is what I did:

I am working off the standard example. If I run the code I get the following error:

Can anyone tell me what I am doing wrong?

2 Answers

I got this error in my code some days ago, but now I’m not getting it anymore and I don’t know why. :/ I did exactly what you did. Try restarting the IDE and the phone! hahaha Who knows? 😛

I got it working. It is nice that Qt has a lot of documentation but the code examples are always so cryptic that it is hard to learn how to use them. After a endless search I accidentally found a solution in a Symbian tutorial. I would suggest that they add a section with things you should know to understand the help for a package as they do with Ubuntu.

So it is not possible to use a relative path in your code. The error message comes because it does not find the file. To make sure your (sound) files are attached to the project create a resource file. Therefore right click on the project name and choose «add» from the menu. In the dialog box select «Qt» and «Resource» and click okay. A new dialog opens asking for a prefix, here use «/». Now your project tree should have a new folder «Resources». Within that folder is a file called «resources.qrc». Double click it and you will get dialog allowing you to add resources such as images and sounds. Click «add» and then «file» and navigate to your file. Personally I add a resource or sounds folde right in my project folder where I already have stored the files I want to add to the project. Choose these files now to add them. They should appear in the main window now. To use a resource in your code do a right click on the file you want to use and choose «copy path» from the menu. Within your code you have to use the path like this:

This worked nicely for me because the audio files, images etc. get packaged with the project and you do not have to worry about getting your resources to the phone.

@Brundu: I think you got it working because you somehow managed to get the file to your phone.

Источник

Qsoundeffect qaudio error decoding source

Hi,
does somebody know why I’m getting this error when trying to play a sound on Android?

W/Qt (16485): audioqsoundeffect_qaudio_p.cpp:354 (void PrivateSoundSource::decoderError()): QSoundEffect(qaudio): Error decoding source

I am using QSound like:

and mysound.wav-file is located as «../sounds/mysound.wav» states. And everything works perfectly on Windows. What could be wrong?

Should I possibly configure .pro-file somehow to make sounds deploy with app?

Are you really sure the file can be found on Android ?

No, I’m not sure. I don’t know if Qt copies that file automatically on Android device or not.

But if it doesn’t, then what should I do to fix it?

I would like to configure Qt to somehow copy that file for me, because in the future I need to make a complete .apk file, which should contain everything that my app needs for running correctly.

So, I created assets-folder under myproject/android/, and moved sounds there, and now they DO work on my phone when I call
@ QSound::play( «assets:/sounds/mysound.wav );@

There is just one drawback — that broke sounds on my Windows environment.
.
.
.
Is there any elegant way to tell Qt to call
@ QSound::play( «assets:/sounds/mysound.wav );@
in Android, and
@ QSound::play( «../my/path/sounds/mysound.wav » );@
in Windows?
.
.
.
p.s. Even QSound::play(«android/assets/sounds/mysound.wav «); won’t work in Windows. The problem seems to be related to ./android-path, because sounds in other directories do work. Any ideas why?

@#ifdef Q_OS_ANDROID
QString mySoundPath = «assets:/sounds/mysound.wav»;
#else
QString mySoundPath = «../my/path/sounds/mysound.wav»;
#endif
QSound::play(mySoundPath);
@

You are giving a relative path, so the folders containing your sound should be at the same level as you executable, which is not the case using a shadow build

Once again, your solution worked — thanks!

But how I should reference to my sounds directory on Windows, then?

Until now, I have used «../sounds/», which is working, because my sounds are one directory upper than my code files. But when I build the app, the .exe will go two directories lower than sounds directory. And it still works.

I don’t understand?

Good question, maybe you have a copy at the right place ? Or the working directory is modified somehow ?

[quote author=»evocat» date=»1407009118″]Once again, your solution worked — thanks! But how I should reference to my sounds directory on Windows, then? Until now, I have used «../sounds/», which is working, because my sounds are one directory upper than my code files. But when I build the app, the .exe will go two directories lower than sounds directory. And it still works. I don’t understand? [/quote]

Why wouldn’t you use Qt resource file then? It perfectly works with linux and android without any source code changes. I believe windows is not a problem too.

Sure it works on all platform. What must be taken in account now is the size of the audio files. wav being uncompressed it can quickly be too big to be used in a builtin resource file.

Good work. I have I had the same problem.

To resume the steps are the following:

@QT += core gui multimedia@

  1. add QSound in the mainwindow.h
  1. add your sound file under the directory androidsounds (not mandatory)

add the mysound.wav as resource then create a resource.qrc file and put inside the file mysound.wav

in your code load the file in this way:

@sound = new QSound(«:/sounds/done.wav»);@

  1. play the file in this way:

There are several methods as stop(), loop() etc.

Источник

Qsoundeffect qaudio error decoding source

Hi. Why sound doesn’t play?
I tried use mp3 from recources, but it didn’t help. What am I doing wrong?
The click.mp3 located the same folder’s level as MainWindow.

Hi
well you ask it to load it from the current folder which would be the build folder
once the app runs. ( not the project folder)
try to put it there.

Also Im not sure QSound does support mp3 files. all samples i saw always use *.wav.

Hi
well you ask it to load it from the current folder which would be the build folder
once the app runs. ( not the project folder)
try to put it there.

Also Im not sure QSound does support mp3 files. all samples i saw always use *.wav.

@mrjj
I converted to wav, but it didn’t help.

As @mrjj you should also copy the file in your build folder since you are using a relative path.

@SGaist
@mrjj
Thank you!
It helped, but why It doesn’t work from recources?

Your path is not a resource path.

@SGaist
Shurely, I changed code. And I copied path (right click on the recource file in Qt -> copy path)

Updated: all are working, my wrong, thank you.

Источник

I am using Linux now and I was moving an old project onto my computer from a backup. The project was originally made on Windows. One of the features of the project was to play music, but no matter what I do I can’t get it to load the file on my Linux PC.

self.m = QSound(«sound.wav») #worked fine on Windows. On Linux I get: QSoundEffect(pulseaudio): Error decoding source file:sound.wav

I have tried:
QSound(«./sound.wav»)
setting the full path,
creating/using a resource file,
and using a .ogg file. All attempts give the same error. How do I get Qt to play sounds on Linux? (I am using Fedora)

P.S I can load image files just fine, but can’t get sound files to work.

Posts: 791

Threads: 94

Joined: Sep 2019

Reputation:
70

Oct-22-2021, 07:15 AM
(This post was last modified: Oct-22-2021, 07:15 AM by menator01.)

This works for me. To play a ogg file you will need to use QMediaPlayer

#! /usr/bin/env python3.9
from PyQt5.QtMultimedia import QSound
from PyQt5.QtWidgets import QApplication
import sys

app = QApplication(sys.argv)
QSound.play('laser.wav')
sys.exit(app.exec())

Posts: 4,568

Threads: 16

Joined: Feb 2020

Reputation:
264

It likely has to do with which codecs are installed. From the docs:

https://doc.qt.io/qt-5/multimediaoverview.html

Quote:The Qt Multimedia APIs build upon the multimedia framework of the underlying platform. This can mean that support for various codecs or containers can vary between machines, depending on what the end user has installed.

Posts: 893

Threads: 15

Joined: Dec 2016

Reputation:
41

You want QSound or QSoundEffect?

Example playing loop using QSoundEffect

from PyQt5.QtMultimedia import QSoundEffect
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
import sys
 
app = QApplication(sys.argv)
effect = QSoundEffect()
sound_file = 'test.wav'
effect.setSource(QUrl.fromLocalFile(sound_file))
effect.setLoopCount(QSoundEffect.Infinite)
effect.setVolume(0.25);
effect.play()
sys.exit(app.exec())

Posts: 49

Threads: 17

Joined: Nov 2016

Reputation:
0

Thanks for the replies. As it would turn out, this is what ended up working for me:

CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(CURRENT_DIR, "sound.ogg")
url = QtCore.QUrl.fromLocalFile(filename)
player = QtMultimedia.QMediaPlayer()
player.setMedia(QtMultimedia.QMediaContent(url))

asked


2014-08-14 19:34:22 +0200

FloR707 gravatar image

Hi,

I am working on an App that should include sounds but I cannot get it to work. Here is what I did:

import QtMultimedia 5.0
Page {
  [..]
  SoundEffect {
        id: soundGong
        source: "../../sounds/gong.wav"
  }
}

I am working off the standard example.
If I run the code I get the following error:

QSoundEffect(pulseaudio): Error decoding sourc

Can anyone tell me what I am doing wrong?

2 Answers

answered


2014-08-14 20:41:31 +0200

Brudhu gravatar image

I got this error in my code some days ago, but now I’m not getting it anymore and I don’t know why. :/
I did exactly what you did. Try restarting the IDE and the phone! hahaha Who knows? :P

answered


2014-08-15 10:48:11 +0200

FloR707 gravatar image

I got it working. It is nice that Qt has a lot of documentation but the code examples are always so cryptic that it is hard to learn how to use them. After a endless search I accidentally found a solution in a Symbian tutorial. I would suggest that they add a section with things you should know to understand the help for a package as they do with Ubuntu.

So it is not possible to use a relative path in your code. The error message comes because it does not find the file. To make sure your (sound) files are attached to the project create a resource file. Therefore right click on the project name and choose «add» from the menu. In the dialog box select «Qt» and «Resource» and click okay. A new dialog opens asking for a prefix, here use «/».
Now your project tree should have a new folder «Resources». Within that folder is a file called «resources.qrc». Double click it and you will get dialog allowing you to add resources such as images and sounds. Click «add» and then «file» and navigate to your file. Personally I add a resource or sounds folde right in my project folder where I already have stored the files I want to add to the project. Choose these files now to add them. They should appear in the main window now.
To use a resource in your code do a right click on the file you want to use and choose «copy path» from the menu. Within your code you have to use the path like this:

source: "qrc:<paste path>"

This worked nicely for me because the audio files, images etc. get packaged with the project and you do not have to worry about getting your resources to the phone.

@Brundu: I think you got it working because you somehow managed to get the file to your phone.

Question tools

Follow

1 follower

Related questions

  • Home
  • Forum
  • Qt
  • Newbie
  • ‘QSound’: No such file or directory

  1. Default ‘QSound’: No such file or directory

    hi

    when i use :

    1. #include <QSound>

    To copy to clipboard, switch view to plain text mode 

    i get this error message :

    ‘QSound’: No such file or directory

    i added this text to my.pro :

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia


  2. Default Re: ‘QSound’: No such file or directory

    After adding multimedia, did your run qmake again & rebuild ?


  3. Default Re: ‘QSound’: No such file or directory

    solved : I cleaned «build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Debug» and rebuilding my project .

    But I hear no sound

    1. void MainWindow::on_pushButton_clicked()

    2. {

    3. QSound sound(":/Music/exelent.wav");

    4. sound.setLoops(1);

    5. sound.play();

    6. }

    To copy to clipboard, switch view to plain text mode 


  4. Default Re: ‘QSound’: No such file or directory

    I got my program (Qt 5.1 based) to compile with this trick.
    However during runtime I got; QSoundEffect(qaudio): Error decoding source (audio file is played ok in windows player)



  5. Default Re: ‘QSound’: No such file or directory

    Quote Originally Posted by mnokka
    View Post

    I got my program (Qt 5.1 based) to compile with this trick.
    However during runtime I got; QSoundEffect(qaudio): Error decoding source (audio file is played ok in windows player)

    Found solution for the runtime issue; By using QMediaPlayer (Qt5.1 , WIN7 x64) I was able to play .wma and .mp3 files ok


Similar Threads

  1. Replies: 7

    Last Post: 19th May 2017, 18:42

  2. Replies: 4

    Last Post: 15th June 2012, 16:14

  3. Replies: 0

    Last Post: 2nd March 2011, 09:36

  4. Replies: 4

    Last Post: 9th May 2010, 17:18

  5. Replies: 4

    Last Post: 6th August 2008, 10:24

Bookmarks

Bookmarks


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules

Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.

Понравилась статья? Поделить с друзьями:
  • Python35 dll ошибка
  • Qserialport timeout error
  • Python яндекс практикум обработка ошибок
  • Qsave ошибка сохранения копии проектных данных неверное имя файла проекта
  • Qrator http 431 поля заголовка запроса слишком велики как исправить