mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 04:18:36 +00:00
Implemented jumping to position in audio file (position slider). Part of issue #48. Updating position slider during playback remains to be done.
This commit is contained in:
parent
e97e57ec73
commit
ec40c854fa
@ -208,3 +208,7 @@ void PlaybackQueue::SetVolume(short volume){
|
||||
this->transport.ChangeVolume(volume);
|
||||
}
|
||||
|
||||
void PlaybackQueue::JumpToPosition(short relativePosition)
|
||||
{
|
||||
this->transport.JumpToPosition(relativePosition);
|
||||
}
|
@ -99,6 +99,7 @@ class PlaybackQueue : public sigslot::has_slots<>{
|
||||
|
||||
short Volume() const;
|
||||
void SetVolume(short volume);
|
||||
void JumpToPosition(short relativePosition);
|
||||
|
||||
musik::core::TrackPtr CurrentTrack();
|
||||
|
||||
|
@ -59,13 +59,13 @@ private: unsigned long streamId;
|
||||
public: unsigned long GetStreamId() const { return this->streamId; };
|
||||
public: utfstring ToString() const;
|
||||
|
||||
public: unsigned long GetLength() const;
|
||||
public: unsigned long GetPosition() const;
|
||||
public: bool SetPosition(unsigned long MS);
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Pending stuff
|
||||
|
||||
// Change modifiers as required. Sticking to private untill really used outside of the class.
|
||||
private: unsigned long GetLength() const;
|
||||
private: unsigned long GetPosition() const;
|
||||
private: bool SetPosition(unsigned long MS);
|
||||
|
||||
// TODO: decide what to do with this when integrating into mC2
|
||||
int GetCrossfadeTime() {return 0;}; // TuniacApp.Preferences
|
||||
|
@ -121,6 +121,15 @@ void Transport::Stop(size_t idx)
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::JumpToPosition(short relativePosition)
|
||||
{
|
||||
AudioStream* stream = this->openStreams[0];
|
||||
|
||||
unsigned long posMS = stream->GetLength() * relativePosition / 100;
|
||||
|
||||
stream->SetPosition(posMS);
|
||||
}
|
||||
|
||||
void Transport::ChangeVolume(short volume)
|
||||
{
|
||||
if (volume < 0 || volume > 100)
|
||||
|
@ -59,6 +59,8 @@ public: ~Transport();
|
||||
public: void Start(const utfstring path);
|
||||
public: void Stop(size_t idx);
|
||||
|
||||
public: void JumpToPosition(short relativePosition);
|
||||
|
||||
public: void ChangeVolume(short volume);
|
||||
public: short Volume() const { return currVolume; };
|
||||
|
||||
|
@ -77,6 +77,9 @@ void TransportController::OnViewCreated(Window* window)
|
||||
musik::core::PlaybackQueue::Instance().Volume());
|
||||
|
||||
musik::core::PlaybackQueue::Instance().CurrentTrackChanged.connect(this,&TransportController::OnTrackChange);
|
||||
|
||||
this->transportView.playbackSlider->Repositioned.connect(
|
||||
this, &TransportController::OnPlaybackSliderChange);
|
||||
}
|
||||
|
||||
void TransportController::OnViewResized(Window* window, Size size)
|
||||
@ -132,3 +135,7 @@ void TransportController::OnTrackChange(musik::core::TrackPtr track){
|
||||
|
||||
}
|
||||
|
||||
void TransportController::OnPlaybackSliderChange(Trackbar *trackBar)
|
||||
{
|
||||
musik::core::PlaybackQueue::Instance().JumpToPosition(trackBar->Position());
|
||||
}
|
@ -64,6 +64,7 @@ protected: void OnNextPressed(Button* button);
|
||||
protected: void OnPreviousPressed(Button* button);
|
||||
protected: void OnVolumeSliderChange(Trackbar* trackbar);
|
||||
protected: void OnTrackChange(musik::core::TrackPtr track);
|
||||
protected: void OnPlaybackSliderChange(Trackbar* trackBar);
|
||||
|
||||
protected: TransportView& transportView;
|
||||
};
|
||||
|
@ -70,29 +70,29 @@ void TransportView::OnCreated()
|
||||
this->stopButton->Resize(50, 28);
|
||||
this->nextButton->Resize(50, 28);
|
||||
|
||||
// now playing layout
|
||||
FontRef boldFont(Font::Create());
|
||||
boldFont->SetBold(true);
|
||||
//
|
||||
LinearLayout* nowPlayingLayout = new LinearLayout(LinearColumnLayout);
|
||||
//
|
||||
nowPlayingLayout->AddChild(new Label(_T("Now playing ")));
|
||||
this->titleLabel = nowPlayingLayout->AddChild(new Label(_T("Song Title")));
|
||||
nowPlayingLayout->AddChild(new Label(_T(" by ")));
|
||||
this->artistLabel = nowPlayingLayout->AddChild(new Label(_T("Artist Name")));
|
||||
//
|
||||
this->titleLabel->SetFont(boldFont);
|
||||
this->artistLabel->SetFont(boldFont);
|
||||
nowPlayingLayout->SetSpacing(0);
|
||||
//
|
||||
Frame* nowPlayingFrame = topRowLayout->AddChild(
|
||||
new Frame(nowPlayingLayout, FramePadding(6, 0, 0, 0)));
|
||||
topRowLayout->SetChildFill(nowPlayingFrame, false);
|
||||
topRowLayout->SetChildAlignment(nowPlayingFrame, ChildAlignCenter);
|
||||
topRowLayout->SetFlexibleChild(nowPlayingFrame);
|
||||
// now playing layout
|
||||
FontRef boldFont(Font::Create());
|
||||
boldFont->SetBold(true);
|
||||
//
|
||||
LinearLayout* nowPlayingLayout = new LinearLayout(LinearColumnLayout);
|
||||
//
|
||||
nowPlayingLayout->AddChild(new Label(_T("Now playing ")));
|
||||
this->titleLabel = nowPlayingLayout->AddChild(new Label(_T("Song Title")));
|
||||
nowPlayingLayout->AddChild(new Label(_T(" by ")));
|
||||
this->artistLabel = nowPlayingLayout->AddChild(new Label(_T("Artist Name")));
|
||||
//
|
||||
this->titleLabel->SetFont(boldFont);
|
||||
this->artistLabel->SetFont(boldFont);
|
||||
nowPlayingLayout->SetSpacing(0);
|
||||
//
|
||||
Frame* nowPlayingFrame = topRowLayout->AddChild(
|
||||
new Frame(nowPlayingLayout, FramePadding(6, 0, 0, 0)));
|
||||
topRowLayout->SetChildFill(nowPlayingFrame, false);
|
||||
topRowLayout->SetChildAlignment(nowPlayingFrame, ChildAlignCenter);
|
||||
topRowLayout->SetFlexibleChild(nowPlayingFrame);
|
||||
|
||||
this->volumeSlider = topRowLayout->AddChild(new Trackbar());
|
||||
this->volumeSlider->Resize(100, 28);
|
||||
this->volumeSlider = topRowLayout->AddChild(new Trackbar());
|
||||
this->volumeSlider->Resize(100, 28);
|
||||
|
||||
// bottom row layout
|
||||
this->timeElapsedLabel = bottomRowLayout->AddChild(new Label(_T("0:00")));
|
||||
|
Loading…
x
Reference in New Issue
Block a user