Player::Player(QWidget *parent) : QWidget(parent) , videoWidget(0) , coverLabel(0) , slider(0) , audioEndpointSelector(0) #ifdef Q_OS_SYMBIAN // , mediaKeysObserver(0) , playlistDialog(0) , toggleAspectRatio(0) , showYoutubeDialog(0) , youtubeDialog(0) #else , colorDialog(0) #endif { player = new QMediaPlayer(this); // owned by PlaylistModel playlist = new QMediaPlaylist(); player->setPlaylist(playlist); connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64))); connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64))); connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged())); connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int))); connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(statusChanged(QMediaPlayer::MediaStatus))); connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int))); connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage())); videoWidget = new VideoWidget(this); player->setVideoOutput(videoWidget); playlistModel = new PlaylistModel(this); playlistModel->setPlaylist(playlist); playlistView = new QListView(this); playlistView->setModel(playlistModel); playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex))); slider = new QSlider(Qt::Horizontal, this); slider->setRange(0, player->duration() / 1000); connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int))); QMediaService *service = player->service(); if (service) { QMediaControl *control = service->requestControl(QAudioEndpointSelector_iid); if (control) { audioEndpointSelector = qobject_cast<QAudioEndpointSelector*>(control); if (audioEndpointSelector) { connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)), this, SLOT(handleAudioOutputChangedSignal(const QString&))); } else { service->releaseControl(control); } } }
void QGraphicsVideoItemPrivate::clearService() { if (windowControl) { QObject::disconnect(windowControl, SIGNAL(nativeSizeChanged()), q_ptr, SLOT(_q_updateNativeSize())); service->releaseControl(windowControl); windowControl = 0; } if (service) { QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); service = 0; } }
void QGraphicsVideoItemPrivate::clearService() { if (rendererControl) { surface->stop(); rendererControl->setSurface(0); service->releaseControl(rendererControl); rendererControl = 0; } if (service) { QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); service = 0; } }