Reputation: 37
I'm trying to add background music to a small application. I'm using Window7 and MinGW but I get this error:
ASSERT: "!url.isRelative() && (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))" in file qml\qqmltypeloader.cpp, line 1639 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function.
This is the code:
import QtQuick 2.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtMultimedia 5.8
Rectangle {
id: main
width: 600
height: 400
state: "mainMenu"
property int margePixel: 30
property int tailleInfoJeux: 200
Image {
id: background
source:"qrc:/images/mainbkg"
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
sourceSize.height: 800
}
MediaPlayer{
id: musicBkg
source: "file:///Users/COMPUTER/Documents/candycrush/candy-crush-like-master/sound/bkg1.wav"
autoLoad: true
autoPlay: false
volume: 1.0
loops: Audio.Infinite
Component.onCompleted: {
//console.log(source==Qt.resolvedUrl("file:///Users/COMPUTER/Documents/candycrush/candy-crush-like-master/sound/Kalimba.mp3"))
console.log(musicBkg.supportedAudioRoles())
}
}
}
this is the .pro file
# Add more folders to ship with the application, here
folder_01.source = qml/SweetCandy
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
# Additional import path used to resolve QML modules in Creator's code model
QML_IMPORT_PATH =
# The .cpp file which was generated for your project. Feel free to hack it.
SOURCES += main.cpp \
bonbon.cpp \
niveau.cpp \
case.cpp \
controleur.cpp
# Installation path
# target.path =
QT += multimedia
# Please do not modify the following two lines. Required for deployment.
include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
qtcAddDeployment()
OTHER_FILES += \
qml/SweetCandy/main.qml \
qml/SweetCandy/VueBonbon.qml \
qml/SweetCandy/VueCase.qml
HEADERS += \
bonbon.h \
niveau.h \
case.h \
controleur.h
RESOURCES += \
ressources.qrc
ICON = SweetCandyIconeLinux.png
macx: ICON = SweetCandyIconeMac.icns
win32: RC_FILE = SweetCandy.rc
Upvotes: 0
Views: 215
Reputation: 85
Try this,
source: "file:///c:\Users\COMPUTER\Documents\candycrush\candy-crush-like-master\sound\bkg1.wav"
Upvotes: 0