void LayerSound::loadDomElement( QDomElement element, QString dataDirPath ) { if ( !element.attribute( "id" ).isNull() ) { int myId = element.attribute( "id" ).toInt(); setId( myId ); } mName = element.attribute( "name" ); mVisible = ( element.attribute( "visibility" ).toInt() == 1 ); QDomNode soundTag = element.firstChild(); while ( !soundTag.isNull() ) { QDomElement soundElement = soundTag.toElement(); if ( soundElement.isNull() ) { continue; } if ( soundElement.tagName() == "sound" ) { QString soundFile = soundElement.attribute( "src" ); // the file is supposed to be in the data directory QString fullPath = QDir( dataDirPath ).filePath( soundFile ); qDebug() << "Load Sound path = " << fullPath; //added for debugging puproses int position = soundElement.attribute( "frame" ).toInt(); Status st = loadSoundAtFrame( fullPath, position ); Q_ASSERT( st.ok() ); } soundTag = soundTag.nextSibling(); } }
void LayerSound::loadDomElement(QDomElement element, QString filePath) { if (!element.attribute("id").isNull()) id = element.attribute("id").toInt(); name = element.attribute("name"); visible = (element.attribute("visibility") == "1"); type = element.attribute("type").toInt(); QDomNode soundTag = element.firstChild(); while (!soundTag.isNull()) { QDomElement soundElement = soundTag.toElement(); if (!soundElement.isNull()) { if (soundElement.tagName() == "sound") { qDebug() << "LAYERSOUND: filePath:" << filePath; //debug information added by #shoshon# QString path = filePath + "/" + PFF_LAYERS_DIR + "/" + soundElement.attribute("src"); // the file is supposed to be in the data directory QFileInfo fi(path); if (!fi.exists()) path = soundElement.attribute("src"); int position = soundElement.attribute("position").toInt(); loadSoundAtFrame( path, position ); } } soundTag = soundTag.nextSibling(); } }