Skip to content

Commit

Permalink
Updated to tlRender. Made audio play when changing frame rates. Made …
Browse files Browse the repository at this point in the history
…audio play when stepping through frames.
  • Loading branch information
ggarra13 committed Oct 11, 2023
1 parent 5f81602 commit f17b0ae
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 22 deletions.
5 changes: 4 additions & 1 deletion mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ v0.8.0
ones.
- Added a cmd.getVersion() to get the version of mrv2 from Python.
- Made playback play with audio when changing frame rate (slower or faster).
- Made audio play when stepping through frames. It is currently a hack and not
a proper fix yet. Also, the stepping buttons are not updated properly.
- Fixed a locale change when using the FPS pull-down and there were thumbnails
present.
- Fixed macOS menu bar font size when switching from macOS menus back to normal
Expand All @@ -32,7 +34,8 @@ v0.8.0
Python to set the input color space of the image.
- Added image.ocioView(), image.setOcioView() and image.ocioViewList() to
Python to set the Display/View color space and to retrieve a list of all
Display/Views.
Display/Views.
- Sped up and removed some bugs in reverse playback.


v0.7.9
Expand Down
58 changes: 51 additions & 7 deletions mrv2/lib/mrvFl/mrvTimelinePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,66 @@ namespace mrv
timelineViewport->updateUndoRedoButtons();
}

void TimelinePlayer::framePrev()
struct StopData
{
pushMessage("framePrev", 0);
_p->timelinePlayer->framePrev();
TimelinePlayer* player;
double speed;
otio::RationalTime time;
};

void stop_playback_cb(StopData* data)
{
auto player = data->player;
player->player()->setPlayback(timeline::Playback::Stop);
player->seek(data->time);
player->setSpeed(data->speed);
player->updateUndoRedoButtons();
redrawPanelThumbnails();
delete data;
}

void TimelinePlayer::updateUndoRedoButtons() const
{
if (timelineViewport)
{
timelineViewport->updateUndoRedoButtons();
timelineViewport->updatePlaybackButtons();
}
}

void TimelinePlayer::framePrev()
{
pushMessage("framePrev", 0);
//_p->timelinePlayer->framePrev();
auto time = currentTime() -
otime::RationalTime(1.0, timeRange().duration().rate());
_p->timelinePlayer->setPlayback(timeline::Playback::Reverse);
StopData* data = new StopData;
data->player = this;
data->time = time;
data->speed = speed();

Fl::add_timeout(
1.75 / speed(), (Fl_Timeout_Handler)stop_playback_cb, data);
}

void TimelinePlayer::frameNext()
{
pushMessage("frameNext", 0);
_p->timelinePlayer->frameNext();
redrawPanelThumbnails();
if (timelineViewport)
timelineViewport->updateUndoRedoButtons();
//_p->timelinePlayer->frameNext();

auto time = currentTime() +
otime::RationalTime(1.0, timeRange().duration().rate());
_p->timelinePlayer->setPlayback(timeline::Playback::Forward);
StopData* data = new StopData;
data->player = this;
data->time = time;
data->speed = speed();
Fl::add_timeout(
1.75 / speed(), (Fl_Timeout_Handler)stop_playback_cb, data);

// if (timelineViewport)
// timelineViewport->updateUndoRedoButtons();
}

void TimelinePlayer::setInOutRange(const otime::TimeRange& value)
Expand Down
3 changes: 3 additions & 0 deletions mrv2/lib/mrvFl/mrvTimelinePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ namespace mrv
//! Returns whtehr annotation at current time can be redone.
bool hasRedo() const;

//! Update Undo/Redo draw buttons after a frame change.
void updateUndoRedoButtons() const;

protected:
template < typename T >
void pushMessage(const std::string& command, const T& value);
Expand Down
16 changes: 8 additions & 8 deletions mrv2/lib/mrvGL/mrvTimelineViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ namespace mrv
}
}

void TimelineViewport::_updatePlaybackButtons() const noexcept
void TimelineViewport::updatePlaybackButtons() const noexcept
{
TLRENDER_P();
if (p.timelinePlayers.empty())
Expand Down Expand Up @@ -337,7 +337,7 @@ namespace mrv
{
i->start();
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.skippedFrames = 0;
}

Expand All @@ -348,7 +348,7 @@ namespace mrv
{
i->framePrev();
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.skippedFrames = 0;
}

Expand All @@ -359,7 +359,7 @@ namespace mrv
{
i->frameNext();
}
_updatePlaybackButtons();
updatePlaybackButtons();
}

void TimelineViewport::endFrame() noexcept
Expand All @@ -379,7 +379,7 @@ namespace mrv
{
i->setPlayback(timeline::Playback::Reverse);
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.ui->uiMain->fill_menu(p.ui->uiMenuBar);
}

Expand All @@ -391,7 +391,7 @@ namespace mrv
{
i->setPlayback(timeline::Playback::Stop);
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.ui->uiMain->fill_menu(p.ui->uiMenuBar);
}

Expand All @@ -403,7 +403,7 @@ namespace mrv
{
i->setPlayback(timeline::Playback::Forward);
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.ui->uiMain->fill_menu(p.ui->uiMenuBar);
}

Expand All @@ -415,7 +415,7 @@ namespace mrv
{
i->togglePlayback();
}
_updatePlaybackButtons();
updatePlaybackButtons();
p.ui->uiMain->fill_menu(p.ui->uiMenuBar);
}

Expand Down
5 changes: 3 additions & 2 deletions mrv2/lib/mrvGL/mrvTimelineViewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ namespace mrv
void editText(
const std::shared_ptr< draw::Shape >&, const int index) noexcept;

//! Update the playback buttons.
void updatePlaybackButtons() const noexcept;

protected:
virtual void _readPixel(image::Color4f& rgba) const noexcept = 0;
math::Vector2i _getViewportCenter() const noexcept;
Expand Down Expand Up @@ -413,8 +416,6 @@ namespace mrv

bool _hasSecondaryViewport() const noexcept;

void _updatePlaybackButtons() const noexcept;

TLRENDER_PRIVATE();
};
} // namespace mrv
8 changes: 5 additions & 3 deletions mrv2/lib/mrvWidgets/mrViewer.fl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ where Yn is the white reference (usually 1).} xywh {5 5 100 20}
}
}

widget_class TimelineClass {
widget_class TimelineClass {open
xywh {130 292 690 29} resizable
class Fl_Double_Window visible
} {
Expand Down Expand Up @@ -567,7 +567,7 @@ player->setLoop( loop );}
callback {int idx = o->value();
double speed = atof( o->text( idx ) );
uiFPS->value( speed );
uiFPS->do_callback();}
uiFPS->do_callback();} selected
tooltip {Some default frame rate settings.} xywh {341 1 40 24} labelsize 10 align 16
code0 {o->disable_label();}
class {mrv::PopupMenu}
Expand Down Expand Up @@ -645,6 +645,8 @@ player->setSpeed( speed );}
code0 {o->textcolor( FL_BLACK );
o->value(24);}
code1 {o->step(0.001);}
code2 {o->minimum(1);}
code3 {o->maximum(60.0);}
class Fl_Value_Input
}
}
Expand Down Expand Up @@ -859,7 +861,7 @@ if (!player) return;
player->setVideoLayer( o->value() );
auto model = v->app->filesModel();
auto item = model->observeA()->get();
model->setLayer(item, o->value());} open selected
model->setLayer(item, o->value());} open
tooltip {Allows you to select different image channels or layers.} xywh {3 26 122 25} box ROUNDED_BOX labelsize 12
class {mrv::PopupMenu}
} {}
Expand Down
2 changes: 1 addition & 1 deletion tlRender

0 comments on commit f17b0ae

Please sign in to comment.