Commit b06725cc authored by Nidhi Jain's avatar Nidhi Jain Committed by Albert Astals Cid

Fix to allow having two audio links in the same epub

REVIEW: 120685
parent c417e8c8
...@@ -246,43 +246,41 @@ QTextDocument* Converter::convert( const QString &fileName ) ...@@ -246,43 +246,41 @@ QTextDocument* Converter::convert( const QString &fileName )
// handle embedded videos // handle embedded videos
QDomNodeList videoTags = dom.elementsByTagName("video"); QDomNodeList videoTags = dom.elementsByTagName("video");
if(!videoTags.isEmpty()) { while(!videoTags.isEmpty()) {
for (int i = 0; i < videoTags.size(); ++i) { QDomNodeList sourceTags = videoTags.at(0).toElement().elementsByTagName("source");
QDomNodeList sourceTags = videoTags.at(i).toElement().elementsByTagName("source"); if(!sourceTags.isEmpty()) {
if(!sourceTags.isEmpty()) { QString lnk = sourceTags.at(0).toElement().attribute("src");
QString lnk = sourceTags.at(0).toElement().attribute("src");
Okular::Movie *movie = new Okular::Movie(mTextDocument->loadResource(EpubDocument::MovieResource,QUrl(lnk)).toString());
Okular::Movie *movie = new Okular::Movie(mTextDocument->loadResource(EpubDocument::MovieResource,QUrl(lnk)).toString()); movie->setSize(videoSize);
movie->setSize(videoSize); movie->setShowControls(true);
movie->setShowControls(true);
Okular::MovieAnnotation *annot = new Okular::MovieAnnotation;
Okular::MovieAnnotation *annot = new Okular::MovieAnnotation; annot->setMovie(movie);
annot->setMovie(movie);
movieAnnots.push_back(annot);
movieAnnots.push_back(annot); QDomDocument tempDoc;
QDomDocument tempDoc; tempDoc.setContent(QString("<pre>&lt;video&gt;&lt;/video&gt;</pre>"));
tempDoc.setContent(QString("<pre>&lt;video&gt;&lt;/video&gt;</pre>")); videoTags.at(0).parentNode().replaceChild(tempDoc.documentElement(),videoTags.at(0));
videoTags.at(i).parentNode().replaceChild(tempDoc.documentElement(),videoTags.at(i));
}
} }
} }
//handle embedded audio //handle embedded audio
QDomNodeList audioTags = dom.elementsByTagName("audio"); QDomNodeList audioTags = dom.elementsByTagName("audio");
if(!audioTags.isEmpty()) { while(!audioTags.isEmpty()) {
for (int i = 0; i < audioTags.size(); ++i) { QDomElement element = audioTags.at(0).toElement();
QString lnk = audioTags.at(i).toElement().attribute("src"); bool repeat = element.hasAttribute("loop");
QString lnk = element.attribute("src");
Okular::Sound *sound = new Okular::Sound(mTextDocument->loadResource( Okular::Sound *sound = new Okular::Sound(mTextDocument->loadResource(
EpubDocument::AudioResource, QUrl(lnk)).toByteArray()); EpubDocument::AudioResource, QUrl(lnk)).toByteArray());
Okular::SoundAction *soundAction = new Okular::SoundAction(1.0,true,true,false,sound); Okular::SoundAction *soundAction = new Okular::SoundAction(1.0,true,repeat,false,sound);
soundActions.push_back(soundAction); soundActions.push_back(soundAction);
QDomDocument tempDoc; QDomDocument tempDoc;
tempDoc.setContent(QString("<pre>&lt;audio&gt;&lt;/audio&gt;</pre>")); tempDoc.setContent(QString("<pre>&lt;audio&gt;&lt;/audio&gt;</pre>"));
audioTags.at(i).parentNode().replaceChild(tempDoc.documentElement(),audioTags.at(i)); audioTags.at(0).parentNode().replaceChild(tempDoc.documentElement(),audioTags.at(0));
}
} }
htmlContent = dom.toString(); htmlContent = dom.toString();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment