| 855 | } |
| 856 | |
| 857 | void MainWidget::handleAudioUpdate(const Media::Player::TrackState &state) { |
| 858 | using State = Media::Player::State; |
| 859 | const auto document = state.id.audio(); |
| 860 | const auto item = session().data().message(state.id.contextId()); |
| 861 | if (!Media::Player::IsStoppedOrStopping(state.state)) { |
| 862 | const auto ttlSeconds = item |
| 863 | && item->media() |
| 864 | && item->media()->ttlSeconds(); |
| 865 | if (!ttlSeconds) { |
| 866 | createPlayer(); |
| 867 | } |
| 868 | } else if (state.state == State::StoppedAtStart) { |
| 869 | Media::Player::instance()->stopAndClose(); |
| 870 | } |
| 871 | |
| 872 | if (item) { |
| 873 | session().data().requestItemRepaint(item); |
| 874 | } |
| 875 | if (document) { |
| 876 | if (const auto items = InlineBots::Layout::documentItems()) { |
| 877 | if (const auto i = items->find(document); i != items->end()) { |
| 878 | for (const auto &item : i->second) { |
| 879 | item->update(); |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | void MainWidget::closeBothPlayers() { |
| 887 | if (_player) { |
nothing calls this directly
no test coverage detected