[UI] Setting min width for Mediaplayer. Added buttons for loop/shuffle
This commit is contained in:
@@ -318,13 +318,6 @@
|
||||
</div>
|
||||
</message>
|
||||
|
||||
<message id="mediaplayer-loopshuffle">
|
||||
<div class="btn-group" role="group" aria-label="...">
|
||||
${loop}
|
||||
${shuffle}
|
||||
</div>
|
||||
</message>
|
||||
|
||||
</messages>
|
||||
|
||||
|
||||
|
||||
@@ -33,24 +33,27 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WContainerWidget *parent)
|
||||
_mediaResource(nullptr)
|
||||
{
|
||||
this->setStyleClass("mediaplayer");
|
||||
this->setHeight(100);
|
||||
this->setHeight(90);
|
||||
|
||||
Wt::WVBoxLayout* mainLayout = new Wt::WVBoxLayout();
|
||||
this->setLayout(mainLayout);
|
||||
|
||||
Wt::WContainerWidget *sliderContainer = new Wt::WContainerWidget(this);
|
||||
Wt::WHBoxLayout *sliderLayout = new Wt::WHBoxLayout();
|
||||
sliderContainer->setLayout(sliderLayout);
|
||||
mainLayout->addLayout(sliderLayout);
|
||||
|
||||
sliderLayout->addWidget(_curTime = new Wt::WText("00:00:00"));
|
||||
_curTime->setLineHeight(30);
|
||||
sliderLayout->addWidget(_timeSlider = new Wt::WSlider( ), 1);
|
||||
_timeSlider->setHeight(30);
|
||||
sliderLayout->addWidget(_duration = new Wt::WText("00:00:00"));
|
||||
_duration->setLineHeight(30);
|
||||
|
||||
Wt::WContainerWidget *controlsContainer = new Wt::WContainerWidget(this);
|
||||
Wt::WHBoxLayout *controlsLayout = new Wt::WHBoxLayout();
|
||||
controlsContainer->setLayout(controlsLayout);
|
||||
|
||||
mainLayout->addLayout(controlsLayout);
|
||||
|
||||
Wt::WContainerWidget *btnContainer = new Wt::WContainerWidget();
|
||||
// Do not allow button to wrap
|
||||
btnContainer->setMinimumSize(155, Wt::WLength::Auto);
|
||||
|
||||
Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("mediaplayer-controls"), btnContainer);
|
||||
|
||||
@@ -78,45 +81,23 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WContainerWidget *parent)
|
||||
_volumeSlider->setRange(0,100);
|
||||
_volumeSlider->setWidth(60);
|
||||
_volumeSlider->setMinimumSize(60, Wt::WLength::Auto);
|
||||
_volumeSlider->setHeight(30);
|
||||
controlsLayout->addWidget(_volumeSlider, 1);
|
||||
|
||||
{
|
||||
Wt::WContainerWidget *loopShuffleContainer = new Wt::WContainerWidget();
|
||||
Wt::WPushButton *loop = new Wt::WPushButton("Loop");
|
||||
loop->setCheckable(true);
|
||||
loop->setStyleClass("btn-xs");
|
||||
loop->checked().connect(std::bind([=] () { _loop.emit( true ); }));
|
||||
loop->unChecked().connect(std::bind([=] () { _loop.emit( false ); }));
|
||||
controlsLayout->addWidget(loop);
|
||||
|
||||
Wt::WTemplate *tLoopShuffle = new Wt::WTemplate(Wt::WString::tr("mediaplayer-loopshuffle"), loopShuffleContainer);
|
||||
Wt::WPushButton *shuffle = new Wt::WPushButton("Shuffle");
|
||||
shuffle->setCheckable(true);
|
||||
shuffle->setStyleClass("btn-xs");
|
||||
shuffle->checked().connect(std::bind([=] () { _shuffle.emit( true ); }));
|
||||
shuffle->unChecked().connect(std::bind([=] () { _shuffle.emit( false );}));
|
||||
controlsLayout->addWidget(shuffle);
|
||||
|
||||
|
||||
Wt::WPushButton *loop = new Wt::WPushButton("Loop");
|
||||
tLoopShuffle->bindWidget("loop", loop);
|
||||
loop->setCheckable(true);
|
||||
loop->setStyleClass("btn-sm");
|
||||
loop->checked().connect(std::bind([=] ()
|
||||
{
|
||||
_loop.emit( true );
|
||||
}));
|
||||
loop->unChecked().connect(std::bind([=] ()
|
||||
{
|
||||
_loop.emit( false );
|
||||
}));
|
||||
|
||||
Wt::WPushButton *shuffle = new Wt::WPushButton("Shuffle");
|
||||
tLoopShuffle->bindWidget("shuffle", shuffle);
|
||||
shuffle->setCheckable(true);
|
||||
shuffle->setStyleClass("btn-sm");
|
||||
shuffle->checked().connect(std::bind([=] ()
|
||||
{
|
||||
_shuffle.emit( true );
|
||||
}));
|
||||
shuffle->unChecked().connect(std::bind([=] ()
|
||||
{
|
||||
_shuffle.emit( false );
|
||||
}));
|
||||
|
||||
controlsLayout->addWidget(loopShuffleContainer);
|
||||
}
|
||||
|
||||
_mediaPlayer = new Wt::WMediaPlayer( Wt::WMediaPlayer::Audio, this );
|
||||
_mediaPlayer = new Wt::WMediaPlayer( Wt::WMediaPlayer::Audio, btnContainer );
|
||||
_mediaPlayer->addSource( Wt::WMediaPlayer::OGA, "" );
|
||||
_mediaPlayer->ended().connect(this, &AudioMediaPlayer::handleTrackEnded);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user