Ejemplo n.º 1
0
void SoundQueue::destroyAllSound() {
	_flag |= 8;

	for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
		SoundEntry *entry = (*i);
		if (entry == NULL)
			error("[SoundQueue::destroyAllSound] Invalid entry found in sound queue");

		// Delete entry
		entry->kill();
		SAFE_DELETE(entry);

		i = _soundList.reverse_erase(i);
	}

	updateSubtitles();
}
Ejemplo n.º 2
0
void SoundQueue::clearQueue() {
	Common::StackLock locker(_mutex);

	_flag |= 8;

	for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) {
		SoundEntry *entry = (*i);

		// Delete entry
		entry->close();
		SAFE_DELETE(entry);

		i = _soundList.reverse_erase(i);
	}

	updateSubtitles();
}
Ejemplo n.º 3
0
void VlcControlVideo::updateSubtitleActions()
{
    qDeleteAll(_actionSubList);
    _actionSubList.clear();
    _descSub.clear();
    _idSub.clear();

    if (!(_vlcMediaPlayer->state() == Vlc::Playing || _vlcMediaPlayer->state() == Vlc::Paused)) {
        emit actions(_actionSubList, Vlc::Subtitles);
        emit subtitleTracks(_actionSubList);
        return;
    }

    if (_vlcVideo->subtitleCount() > 0) {
        QStringList desc = _vlcVideo->subtitleDescription();
        //QList<int> ids = _vlcVideo->subtitleIds();
        for (int i = 0; i < desc.size(); i++) {
            _descSub.insert(desc[i], i); //_descSub.insert(desc[i], ids[i]);
            _idSub.insert(i, i);         //_idSub.insert(ids[i], i);
            _actionSubList << new QAction(desc[i], this);
        }
    } else {
        emit actions(_actionSubList, Vlc::Subtitles);
        emit subtitleTracks(_actionSubList);
        _timerSubtitles->start(1000);
        return;
    }

    foreach (QAction *action, _actionSubList) {
        action->setCheckable(true);
        connect(action, SIGNAL(triggered()), this, SLOT(updateSubtitles()));

        if (!_manualLanguage) {
            foreach (const QString &language, _preferedLanguage) {
                if (action->text().contains(language, Qt::CaseInsensitive)) {
                    action->trigger();
                    _manualLanguage = true;
                }
            }
        }
Ejemplo n.º 4
0
void MPlayerMediaWidget::readStandardOutput()
{
	QByteArray data = process.readAllStandardOutput();
	standardError.write(data); // forward
	standardError.flush();

	if ((data == "\n") || (data.indexOf("\n\n") >= 0)) {
		process.write("pausing_keep_force get_property path\n");
	}

	bool videoPropertiesChanged = false;
	QStringList audioStreams = getAudioStreams();
	bool audioStreamsChanged = false;
	QStringList subtitles = getSubtitles();
	bool subtitlesChanged = false;

	foreach (const QByteArray &line, data.split('\n')) {
		if (line.startsWith("VO: ")) {
			videoPropertiesChanged = true;
			continue;
		}

		if (line.startsWith("audio stream: ")) {
			int begin = 14;
			int end = line.indexOf(' ', begin);

			if (end < 0) {
				end = line.size();
			}

			int audioStreamIndex = line.mid(begin, end - begin).toInt();

			while (audioStreams.size() < audioStreamIndex) {
				audioStreams.append(QString::number(audioStreams.size() + 1));
			}

			while (audioIds.size() < audioStreamIndex) {
				audioIds.append(-1);
			}

			audioStreams.erase(audioStreams.begin() + audioStreamIndex,
				audioStreams.end());
			audioIds.erase(audioIds.begin() + audioStreamIndex, audioIds.end());
			QString audioStream;
			begin = line.indexOf("language: ");

			if (begin >= 0) {
				begin += 10;
				end = line.indexOf(' ', begin);

				if (end < 0) {
					end = line.size();
				}

				audioStream = line.mid(begin, end - begin);
			}

			if (audioStream.isEmpty()) {
				audioStream = QString::number(audioStreams.size() + 1);
			}

			int audioId = -1;
			begin = line.indexOf("aid: ");

			if (begin >= 0) {
				begin += 5;
				end = line.indexOf('.', begin);

				if (end < 0) {
					end = line.size();
				}

				audioId = line.mid(begin, end - begin).toInt();
			}

			audioStreams.append(audioStream);
			audioIds.append(audioId);
			audioStreamsChanged = true;
			continue;
		}

		if (line.startsWith("subtitle ")) {
			int begin = line.indexOf("( sid ): ");

			if (begin < 0) {
				continue;
			}

			begin += 9;
			int end = line.indexOf(' ', begin);

			if (end < 0) {
				end = line.size();
			}

			int subtitleIndex = line.mid(begin, end - begin).toInt();

			while (subtitles.size() < subtitleIndex) {
				subtitles.append(QString::number(subtitles.size() + 1));
			}

			subtitles.erase(subtitles.begin() + subtitleIndex, subtitles.end());
			QString subtitle;
			begin = line.indexOf("language: ");

			if (begin >= 0) {
				begin += 10;
				end = line.indexOf(' ', begin);

				if (end < 0) {
					end = line.size();
				}

				subtitle = line.mid(begin, end - begin);
			}

			if (subtitle.isEmpty()) {
				subtitle = QString::number(subtitles.size() + 1);
			}

			subtitles.append(subtitle);
			subtitlesChanged = true;
			continue;
		}

		if (line == "ANS_path=(null)") {
			switch (getPlaybackStatus()) {
			case MediaWidget::Idle:
				break;
			case MediaWidget::Playing:
			case MediaWidget::Paused:
				playbackFinished();
				break;
			}

			resetState();
			continue;
		}

		if (line.startsWith("ANS_length=")) {
			int totalTime = (line.mid(11).toFloat() * 1000 + 0.5);
			updateCurrentTotalTime(getCurrentTime(), totalTime);
			continue;
		}

		if (line.startsWith("ANS_time_pos=")) {
			int currentTime = (line.mid(13).toFloat() * 1000 + 0.5);
			updateCurrentTotalTime(currentTime, getTotalTime());
			continue;
		}

		if (line.startsWith("ANS_width=")) {
			videoWidth = line.mid(10).toInt();

			if (videoWidth < 0) {
				videoWidth = 0;
			}

			continue;
		}

		if (line.startsWith("ANS_height=")) {
			videoHeight = line.mid(11).toInt();

			if (videoHeight < 0) {
				videoHeight = 0;
			}

			continue;
		}

		if (line.startsWith("ANS_aspect=")) {
			videoAspectRatio = line.mid(11).toFloat();

			if ((videoAspectRatio > 0.01) && (videoAspectRatio < 100)) {
				// ok
			} else {
				videoAspectRatio = (videoWidth / float(videoHeight));

				if ((videoAspectRatio > 0.01) && (videoAspectRatio < 100)) {
					// ok
				} else {
					videoAspectRatio = 1;
				}
			}

			updateVideoWidgetGeometry();
			continue;
		}

		if (line.startsWith("ANS_switch_audio=")) {
			int audioId = line.mid(17).toInt();
			updateCurrentAudioStream(audioIds.indexOf(audioId));
			continue;
		}

		if (line.startsWith("ANS_sub=")) {
			int currentSubtitle = line.mid(8).toInt();
			updateCurrentSubtitle(currentSubtitle);
			continue;
		}
	}

	if (videoPropertiesChanged) {
		process.write("pausing_keep_force get_property width\n"
			"pausing_keep_force get_property height\n"
			"pausing_keep_force get_property aspect\n");
	}

	if (audioStreamsChanged) {
		updateAudioStreams(audioStreams);
		process.write("pausing_keep_force get_property switch_audio\n");
	}

	if (subtitlesChanged) {
		updateSubtitles(subtitles);
		process.write("pausing_keep_force get_property sub\n");
	}
}