mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge pull request #3327 from Atlante45/rec_file_format_tweaks
Looping option
This commit is contained in:
commit
bef0232b35
5 changed files with 51 additions and 19 deletions
|
@ -139,7 +139,9 @@ function moveUI() {
|
|||
function mousePressEvent(event) {
|
||||
clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
|
||||
|
||||
if (recordIcon === toolBar.clicked(clickedOverlay)) {
|
||||
print("Status: isPlaying=" + MyAvatar.isPlaying() + ", isRecording=" + MyAvatar.isRecording());
|
||||
|
||||
if (recordIcon === toolBar.clicked(clickedOverlay) && !MyAvatar.isPlaying()) {
|
||||
if (!MyAvatar.isRecording()) {
|
||||
MyAvatar.startRecording();
|
||||
toolBar.setBack(COLOR_ON, ALPHA_ON);
|
||||
|
@ -148,14 +150,14 @@ function mousePressEvent(event) {
|
|||
MyAvatar.loadLastRecording();
|
||||
toolBar.setBack(COLOR_OFF, ALPHA_OFF);
|
||||
}
|
||||
} else if (playIcon === toolBar.clicked(clickedOverlay)) {
|
||||
if (!MyAvatar.isRecording()) {
|
||||
if (MyAvatar.isPlaying()) {
|
||||
MyAvatar.stopPlaying();
|
||||
} else {
|
||||
MyAvatar.startPlaying(true);
|
||||
}
|
||||
}
|
||||
} else if (playIcon === toolBar.clicked(clickedOverlay) && !MyAvatar.isRecording()) {
|
||||
if (MyAvatar.isPlaying()) {
|
||||
MyAvatar.stopPlaying();
|
||||
} else {
|
||||
MyAvatar.setPlayFromCurrentLocation(true);
|
||||
MyAvatar.setPlayerLoop(true);
|
||||
MyAvatar.startPlaying(true);
|
||||
}
|
||||
} else if (saveIcon === toolBar.clicked(clickedOverlay)) {
|
||||
if (!MyAvatar.isRecording()) {
|
||||
recordingFile = Window.save("Save recording to file", ".", "*.rec");
|
||||
|
|
|
@ -637,16 +637,23 @@ void AvatarData::loadRecording(QString filename) {
|
|||
_player->loadFromFile(filename);
|
||||
}
|
||||
|
||||
void AvatarData::startPlaying(bool fromCurrentPosition) {
|
||||
void AvatarData::startPlaying() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(bool, fromCurrentPosition));
|
||||
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
|
||||
return;
|
||||
}
|
||||
if (!_player) {
|
||||
_player = PlayerPointer(new Player(this));
|
||||
}
|
||||
_player->startPlaying(fromCurrentPosition);
|
||||
_player->startPlaying();
|
||||
}
|
||||
|
||||
void AvatarData::setPlayFromCurrentLocation(bool playFromCurrentLocation) {
|
||||
_player->setPlayFromCurrentLocation(playFromCurrentLocation);
|
||||
}
|
||||
|
||||
void AvatarData::setPlayerLoop(bool loop) {
|
||||
_player->setLoop(loop);
|
||||
}
|
||||
|
||||
void AvatarData::play() {
|
||||
|
|
|
@ -303,7 +303,9 @@ public slots:
|
|||
qint64 playerElapsed();
|
||||
qint64 playerLength();
|
||||
void loadRecording(QString filename);
|
||||
void startPlaying(bool fromCurrentPosition = false);
|
||||
void startPlaying();
|
||||
void setPlayFromCurrentLocation(bool playFromCurrentLocation);
|
||||
void setPlayerLoop(bool loop);
|
||||
void play();
|
||||
void stopPlaying();
|
||||
|
||||
|
|
|
@ -166,7 +166,9 @@ Player::Player(AvatarData* avatar) :
|
|||
_recording(new Recording()),
|
||||
_avatar(avatar),
|
||||
_audioThread(NULL),
|
||||
_startingScale(1.0f)
|
||||
_startingScale(1.0f),
|
||||
_playFromCurrentPosition(true),
|
||||
_loop(false)
|
||||
{
|
||||
_timer.invalidate();
|
||||
_options.setLoop(false);
|
||||
|
@ -216,7 +218,7 @@ float Player::getLeanForward() {
|
|||
return _recording->getFrame(_currentFrame).getLeanForward();
|
||||
}
|
||||
|
||||
void Player::startPlaying(bool fromCurrentPosition) {
|
||||
void Player::startPlaying() {
|
||||
if (_recording && _recording->getFrameNumber() > 0) {
|
||||
qDebug() << "Recorder::startPlaying()";
|
||||
_currentFrame = 0;
|
||||
|
@ -233,7 +235,7 @@ void Player::startPlaying(bool fromCurrentPosition) {
|
|||
// Fake faceshift connection
|
||||
_avatar->setForceFaceshiftConnected(true);
|
||||
|
||||
if (fromCurrentPosition) {
|
||||
if (_playFromCurrentPosition) {
|
||||
_startingPosition = _avatar->getPosition();
|
||||
_startingRotation = _avatar->getOrientation();
|
||||
_startingScale = _avatar->getTargetScale();
|
||||
|
@ -288,9 +290,13 @@ void Player::loadRecording(RecordingPointer recording) {
|
|||
|
||||
void Player::play() {
|
||||
computeCurrentFrame();
|
||||
if (_currentFrame < 0 || _currentFrame >= _recording->getFrameNumber() - 1) {
|
||||
if (_currentFrame < 0 || (_currentFrame >= _recording->getFrameNumber() - 1)) {
|
||||
// If it's the end of the recording, stop playing
|
||||
stopPlaying();
|
||||
|
||||
if (_loop) {
|
||||
startPlaying();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -325,6 +331,14 @@ void Player::play() {
|
|||
_injector->setOptions(_options);
|
||||
}
|
||||
|
||||
void Player::setPlayFromCurrentLocation(bool playFromCurrentLocation) {
|
||||
_playFromCurrentPosition = playFromCurrentLocation;
|
||||
}
|
||||
|
||||
void Player::setLoop(bool loop) {
|
||||
_loop = loop;
|
||||
}
|
||||
|
||||
bool Player::computeCurrentFrame() {
|
||||
if (!isPlaying()) {
|
||||
_currentFrame = -1;
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
QVector<qint32> _timestamps;
|
||||
QVector<RecordingFrame> _frames;
|
||||
|
||||
bool _stereo;
|
||||
Sound* _audio;
|
||||
|
||||
friend class Recorder;
|
||||
|
@ -146,12 +147,15 @@ public:
|
|||
|
||||
|
||||
public slots:
|
||||
void startPlaying(bool fromCurrentPosition = false);
|
||||
void startPlaying();
|
||||
void stopPlaying();
|
||||
void loadFromFile(QString file);
|
||||
void loadRecording(RecordingPointer recording);
|
||||
void play();
|
||||
|
||||
void setPlayFromCurrentLocation(bool playFromCurrentLocation);
|
||||
void setLoop(bool loop);
|
||||
|
||||
private:
|
||||
bool computeCurrentFrame();
|
||||
|
||||
|
@ -168,6 +172,9 @@ private:
|
|||
glm::vec3 _startingPosition;
|
||||
glm::quat _startingRotation;
|
||||
float _startingScale;
|
||||
|
||||
bool _playFromCurrentPosition;
|
||||
bool _loop;
|
||||
};
|
||||
|
||||
void writeRecordingToFile(RecordingPointer recording, QString file);
|
||||
|
|
Loading…
Reference in a new issue