2015-07-03 08:47:16 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2015-07-03 08:47:16 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-07-05 17:44:02 +00:00
|
|
|
#include "media/media_audio.h"
|
2015-07-03 08:47:16 +00:00
|
|
|
|
|
|
|
class PlayerWidget : public TWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
PlayerWidget(QWidget *parent);
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void leaveEvent(QEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
|
2015-07-13 17:55:59 +00:00
|
|
|
void playPressed();
|
|
|
|
void pausePressed();
|
|
|
|
void playPausePressed();
|
|
|
|
void prevPressed();
|
|
|
|
void nextPressed();
|
|
|
|
void stopPressed();
|
2016-04-14 16:08:36 +00:00
|
|
|
void closePressed();
|
2015-07-13 17:55:59 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_progress(float64 ms, bool timer);
|
|
|
|
void step_state(uint64 ms, bool timer);
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2016-07-10 13:02:22 +00:00
|
|
|
void updateState(AudioMsgId playing, AudioPlaybackState playbackState);
|
2015-07-03 08:47:16 +00:00
|
|
|
void updateState();
|
|
|
|
void clearSelection();
|
|
|
|
|
|
|
|
void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
|
|
|
|
|
2016-06-30 12:03:32 +00:00
|
|
|
bool seekingSong(const AudioMsgId &song) const;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2016-04-14 16:08:36 +00:00
|
|
|
void openPlayer();
|
|
|
|
bool isOpened() const;
|
|
|
|
void closePlayer();
|
|
|
|
|
|
|
|
void showPlayer();
|
|
|
|
void hidePlayer();
|
|
|
|
|
2015-07-03 10:48:28 +00:00
|
|
|
signals:
|
|
|
|
|
2015-09-03 10:48:40 +00:00
|
|
|
void playerSongChanged(const FullMsgId &msgId);
|
2015-07-03 10:48:28 +00:00
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
private:
|
|
|
|
|
2016-04-14 16:08:36 +00:00
|
|
|
// Use startPlayer()/stopPlayer() or showPlayer()/hidePlayer() instead.
|
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
|
2015-07-03 08:47:16 +00:00
|
|
|
enum OverState {
|
|
|
|
OverNone = 0,
|
|
|
|
OverPrev,
|
|
|
|
OverPlay,
|
|
|
|
OverNext,
|
|
|
|
OverClose,
|
|
|
|
OverVolume,
|
|
|
|
OverFull,
|
2015-07-14 19:07:21 +00:00
|
|
|
OverRepeat,
|
2015-07-03 08:47:16 +00:00
|
|
|
OverPlayback,
|
|
|
|
|
|
|
|
OverStateCount
|
|
|
|
};
|
|
|
|
void updateDownTime();
|
|
|
|
void updateOverState(OverState newState);
|
|
|
|
void updateOverRect(OverState state);
|
|
|
|
|
|
|
|
void updateControls();
|
|
|
|
void findCurrent();
|
2015-11-24 18:24:54 +00:00
|
|
|
void preloadNext();
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2015-09-03 10:48:40 +00:00
|
|
|
void startPlay(const FullMsgId &msgId);
|
2015-07-03 08:47:16 +00:00
|
|
|
|
|
|
|
QPoint _lastMousePos;
|
|
|
|
void updateSelected();
|
|
|
|
|
2016-04-14 16:08:36 +00:00
|
|
|
bool _playerOpened = false;
|
|
|
|
|
|
|
|
bool _prevAvailable = false;
|
|
|
|
bool _nextAvailable = false;
|
|
|
|
bool _fullAvailable = false;
|
|
|
|
OverState _over = OverNone;
|
|
|
|
OverState _down = OverNone;
|
|
|
|
int32 _downCoord = 0;
|
2015-07-03 08:47:16 +00:00
|
|
|
int64 _downDuration;
|
2016-04-14 16:08:36 +00:00
|
|
|
int32 _downFrequency = AudioVoiceMsgFrequency;
|
|
|
|
float64 _downProgress = 0.;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
|
|
|
float64 _stateHovers[OverStateCount];
|
|
|
|
typedef QMap<int32, uint64> StateAnimations;
|
|
|
|
StateAnimations _stateAnimations;
|
2015-12-08 12:33:37 +00:00
|
|
|
Animation _a_state;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2016-06-30 12:03:32 +00:00
|
|
|
AudioMsgId _song;
|
2016-04-14 16:08:36 +00:00
|
|
|
bool _msgmigrated = false;
|
|
|
|
int32 _index = -1;
|
|
|
|
History *_migrated = nullptr;
|
|
|
|
History *_history = nullptr;
|
2015-07-03 08:47:16 +00:00
|
|
|
QRect _playRect, _prevRect, _nextRect, _playbackRect;
|
2015-07-14 19:07:21 +00:00
|
|
|
QRect _closeRect, _volumeRect, _fullRect, _repeatRect, _infoRect;
|
2016-04-14 16:08:36 +00:00
|
|
|
int32 _timeWidth = 0;
|
|
|
|
bool _repeat = false;
|
2015-07-03 08:47:16 +00:00
|
|
|
QString _time;
|
|
|
|
Text _name;
|
2016-04-14 16:08:36 +00:00
|
|
|
bool _showPause = false;
|
|
|
|
int64 _position = 0;
|
|
|
|
int64 _duration = 0;
|
|
|
|
int32 _loaded = 0;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
2016-04-14 16:08:36 +00:00
|
|
|
anim::fvalue a_progress = { 0., 0. };
|
|
|
|
anim::fvalue a_loadProgress = { 0., 0. };
|
2015-12-08 12:33:37 +00:00
|
|
|
Animation _a_progress;
|
2015-07-03 08:47:16 +00:00
|
|
|
|
|
|
|
};
|