diff --git a/mythtv/libs/libmythmetadata/lyricsdata.cpp b/mythtv/libs/libmythmetadata/lyricsdata.cpp
index 8ad688f..7e44390 100644
a
|
b
|
void LyricsData::loadLyrics(const QString &xmlData) |
272 | 272 | QDomNode lyricNode = itemList.at(x); |
273 | 273 | QString lyric = lyricNode.toElement().text(); |
274 | 274 | |
275 | | lyrics.append(lyric); |
| 275 | if (m_syncronized) |
| 276 | { |
| 277 | QStringList times; |
| 278 | int lastind = 0; |
| 279 | while (lyric.indexOf(QRegExp("\\[\\d\\d:\\d\\d\\]"), |
| 280 | lastind) == lastind || |
| 281 | lyric.indexOf(QRegExp("\\[\\d\\d:\\d\\d\\.\\d\\d\\]"), |
| 282 | lastind) == lastind) |
| 283 | { |
| 284 | if (lyric[lastind+6] == '.') |
| 285 | { |
| 286 | times.append(lyric.mid(lastind,10)); |
| 287 | lastind += 10; |
| 288 | } |
| 289 | else |
| 290 | { |
| 291 | // short version |
| 292 | times.append(lyric.mid(lastind,7)); |
| 293 | lastind += 7; |
| 294 | } |
| 295 | } |
| 296 | if (!times.isEmpty()) |
| 297 | { |
| 298 | for (int x = 0; x < times.count(); x++) |
| 299 | { |
| 300 | lyrics.append(times.at(x) + lyric.mid(lastind)); |
| 301 | } |
| 302 | } |
| 303 | else |
| 304 | { |
| 305 | lyrics.append(lyric); |
| 306 | } |
| 307 | } |
| 308 | else |
| 309 | { |
| 310 | lyrics.append(lyric); |
| 311 | } |
276 | 312 | } |
277 | 313 | |
278 | 314 | setLyrics(lyrics); |
… |
… |
void LyricsData::setLyrics(const QStringList &lyrics) |
285 | 321 | clearLyrics(); |
286 | 322 | |
287 | 323 | int lastTime = -1; |
| 324 | int offset = 0; // offset in milliseconds |
288 | 325 | |
289 | 326 | for (int x = 0; x < lyrics.count(); x++) |
290 | 327 | { |
… |
… |
void LyricsData::setLyrics(const QStringList &lyrics) |
292 | 329 | |
293 | 330 | LyricsLine *line = new LyricsLine; |
294 | 331 | |
| 332 | if (lyric.startsWith("[offset:")) |
| 333 | { |
| 334 | offset = lyric.mid(8,lyric.indexOf("]", 8)-8).toInt(); |
| 335 | } |
| 336 | |
295 | 337 | if (m_syncronized) |
296 | 338 | { |
297 | 339 | if (!lyric.isEmpty()) |
298 | 340 | { |
299 | | // does the line start with a time code like [12:34.56] |
300 | | if (lyric.indexOf(QRegExp("\\[\\d\\d:\\d\\d\\.\\d\\d\\]"), 0) == 0) |
| 341 | // does the line start with a time code like [12:34] or [12:34.56] |
| 342 | if (lyric.indexOf(QRegExp("\\[\\d\\d:\\d\\d\\]"), 0) == 0 || |
| 343 | lyric.indexOf(QRegExp("\\[\\d\\d:\\d\\d\\.\\d\\d\\]"), 0) == 0) |
301 | 344 | { |
302 | 345 | int minutes = lyric.mid(1, 2).toInt(); |
303 | 346 | int seconds = lyric.mid(4, 2).toInt(); |
304 | | int hundredths = lyric.mid(7, 2).toInt(); |
| 347 | int hundredths = 0; |
| 348 | if (lyric[6] == '.') |
| 349 | { |
| 350 | hundredths = lyric.mid(7, 2).toInt(); |
| 351 | line->Lyric = lyric.mid(10); |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | line->Lyric = lyric.mid(7); |
| 356 | } |
305 | 357 | line->Time = (minutes * 60 * 1000) + (seconds * 1000) + (hundredths * 10); |
306 | | line->Lyric = lyric.mid(10); |
| 358 | if (offset > 0) |
| 359 | { |
| 360 | if (offset > line->Time) line->Time = 0; |
| 361 | else line->Time -= offset; |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | line->Time -= offset; |
| 366 | } |
307 | 367 | lastTime = line->Time; |
308 | 368 | } |
309 | 369 | else |
… |
… |
void LyricsData::setLyrics(const QStringList &lyrics) |
332 | 392 | // ignore anything that is not a lyric |
333 | 393 | if (line->Lyric.startsWith("[ti:") || line->Lyric.startsWith("[al:") || |
334 | 394 | line->Lyric.startsWith("[ar:") || line->Lyric.startsWith("[by:") || |
335 | | line->Lyric.startsWith("[url:") || line->Lyric.startsWith("[offset:")) |
| 395 | line->Lyric.startsWith("[url:") || line->Lyric.startsWith("[offset:") || |
| 396 | line->Lyric.startsWith("[id:") || line->Lyric.startsWith("[length:") || |
| 397 | line->Lyric.startsWith("[au:") || line->Lyric.startsWith("[la:")) |
336 | 398 | { |
337 | 399 | delete line; |
338 | 400 | continue; |