+ MainWindow::instance()->setupAction(subscribeAction);
+}
+
+void MediaView::updateSubscriptionActionForChannel(const QString & channelId) {
+ QString channelTitle = tr("channel");
+ YTChannel *channel = YTChannel::forId(channelId);
+ if (nullptr != channel && !channel->getDisplayName().isEmpty()) {
+ channelTitle = channel->getDisplayName();
+ }
+
+ bool subscribed = YTChannel::isSubscribed(channelId);
+
+ currentSubscriptionChannelId = channelId;
+ currentSubscriptionChannelTitle = channelTitle;
+ updateSubscriptionAction(subscribed);
+}
+
+void MediaView::updateSubscriptionActionForVideo(Video *video, bool subscribed) {
+ if (!video) {
+ currentSubscriptionChannelId = "";
+ currentSubscriptionChannelTitle = "";
+ updateSubscriptionAction(false);
+ } else {
+ currentSubscriptionChannelId = video->getChannelId();
+ currentSubscriptionChannelTitle = video->getChannelTitle();
+ updateSubscriptionAction(subscribed);
+ }
+}
+
+void MediaView::reloadCurrentVideo() {
+ Video *video = playlistModel->activeVideo();
+ if (!video) return;
+
+ int oldFormat = video->getDefinitionCode();
+
+ QObject *context = new QObject();
+ connect(video, &Video::gotStreamUrl, context,
+ [this, oldFormat, video, context](const QString &videoUrl, const QString &audioUrl) {
+ context->deleteLater();
+ if (oldFormat == video->getDefinitionCode()) return;
+ QObject *context2 = new QObject();
+ const qint64 position = media->position();
+ connect(media, &Media::stateChanged, context2,
+ [position, this, context2](Media::State state) {
+ if (state == Media::PlayingState) {
+ media->seek(position);
+ context2->deleteLater();
+ Video *video = playlistModel->activeVideo();
+ QString msg = tr("Switched to %1")
+ .arg(VideoDefinition::forCode(
+ video->getDefinitionCode())
+ .getName());
+ MainWindow::instance()->showMessage(msg);
+ }
+ });
+
+ if (audioUrl.isEmpty()) {
+ media->play(videoUrl);
+ } else {
+ media->playSeparateAudioAndVideo(videoUrl, audioUrl);
+ }
+ });
+ video->loadStreamUrl();