TitlePlayDialog::TitlePlayDialog(QWidget *parent, AudioPlayerBridge *apb, API *api, Song *song) : QDialog(parent), ui(new Ui::TitlePlayDialog) { this->setAttribute(Qt::WA_QuitOnClose, false); this->setAttribute(Qt::WA_DeleteOnClose); posChanging = false; posTimer = new QTimer(this); posTimer->setInterval(200); posTimer->setSingleShot(false); connect(posTimer, SIGNAL(timeout()), this , SLOT(timerTick())); posTimer->start(); this->apb = new AudioPlayerBridge(this, false); this->apb->setVolume(apb->getVolume()); this->api = api; this->song = song; ui->setupUi(this); this->setWindowFlags(this->windowFlags() & ~(Qt::WindowFullscreenButtonHint)); QRect geometry = QApplication::desktop()->screenGeometry(); this->setGeometry((geometry.width() - this->width()) / 2, (geometry.height() - this->height()) / 2, this->width(), this->height()); this->setFixedSize(this->size()); this->setWindowTitle(QString::fromStdString(song->getSongName() + " - " + song->getArtistName())); ui->lblSong->setText(QString::fromStdString(song->getSongName() + " - " + song->getArtistName())); ui->sldVolume->setValue(this->apb->getVolume()); ui->sldVolume->setStyle(new MyVolumeStyle); ui->sldPosition->setStyle(new MyVolumeStyle); connect(api, SIGNAL(streamKeyReady(StreamInformation*)), this, SLOT(gotSongInformation(StreamInformation*))); connect(this->apb, SIGNAL(startedPlaying()), this, SLOT(songStarted())); connect(this->apb, SIGNAL(songFinished()), this, SLOT(songFinished())); connect(api, SIGNAL(songError(int)), this, SLOT(songFailed(int))); play(); }
void RtpAudioStream::startPlaying() { if (audio_output_) return; QAudioFormat format; format.setSampleRate(audio_out_rate_); format.setSampleSize(sample_bytes_ * 8); // bits format.setSampleType(QAudioFormat::SignedInt); format.setChannelCount(1); format.setCodec("audio/pcm"); // RTP_STREAM_DEBUG("playing %s %d samples @ %u Hz", // tempfile_->fileName().toUtf8().constData(), // (int) tempfile_->size(), audio_out_rate_); audio_output_ = new QAudioOutput(format, this); audio_output_->setNotifyInterval(65); // ~15 fps connect(audio_output_, SIGNAL(stateChanged(QAudio::State)), this, SLOT(outputStateChanged())); connect(audio_output_, SIGNAL(notify()), this, SLOT(outputNotify())); tempfile_->seek(0); audio_output_->start(tempfile_); emit startedPlaying(); // QTBUG-6548 StoppedState is not always emitted on error, force a cleanup // in case playback fails immediately. if (audio_output_ && audio_output_->state() == QAudio::StoppedState) { outputStateChanged(); } }
bool AudioAbstracter::play () { int result = gst_element_set_state (p->decoder, GST_STATE_PLAYING); if (result == GST_STATE_CHANGE_FAILURE) { qDebug() << "AudioAbstracter failed to start playing"; emit sourceUnplayable (); return false; } else { emit startedPlaying (); return true; } }
void RtpPlayerDialog::addRtpStream(struct _rtp_stream_info *rtp_stream) { if (!rtp_stream) return; // Find the RTP streams associated with this conversation. // gtk/rtp_player.c:mark_rtp_stream_to_play does this differently. RtpAudioStream *audio_stream = NULL; int tli_count = ui->streamTreeWidget->topLevelItemCount(); for (int row = 0; row < tli_count; row++) { QTreeWidgetItem *ti = ui->streamTreeWidget->topLevelItem(row); RtpAudioStream *row_stream = ti->data(stream_data_col_, Qt::UserRole).value<RtpAudioStream*>(); if (row_stream->isMatch(rtp_stream)) { audio_stream = row_stream; break; } } if (!audio_stream) { audio_stream = new RtpAudioStream(this, rtp_stream); audio_stream->setColor(ColorUtils::graph_colors_[tli_count % ColorUtils::graph_colors_.length()]); QTreeWidgetItem *ti = new QTreeWidgetItem(ui->streamTreeWidget); ti->setText(src_addr_col_, address_to_qstring(&rtp_stream->src_addr)); ti->setText(src_port_col_, QString::number(rtp_stream->src_port)); ti->setText(dst_addr_col_, address_to_qstring(&rtp_stream->dest_addr)); ti->setText(dst_port_col_, QString::number(rtp_stream->dest_port)); ti->setText(ssrc_col_, int_to_qstring(rtp_stream->ssrc, 8, 16)); ti->setText(first_pkt_col_, QString::number(rtp_stream->setup_frame_number)); ti->setText(num_pkts_col_, QString::number(rtp_stream->packet_count)); ti->setData(stream_data_col_, Qt::UserRole, QVariant::fromValue(audio_stream)); for (int col = 0; col < ui->streamTreeWidget->columnCount(); col++) { ti->setTextColor(col, audio_stream->color()); } connect(ui->playButton, SIGNAL(clicked(bool)), audio_stream, SLOT(startPlaying())); connect(ui->stopButton, SIGNAL(clicked(bool)), audio_stream, SLOT(stopPlaying())); connect(audio_stream, SIGNAL(startedPlaying()), this, SLOT(updateWidgets())); connect(audio_stream, SIGNAL(finishedPlaying()), this, SLOT(updateWidgets())); connect(audio_stream, SIGNAL(processedSecs(double)), this, SLOT(setPlayPosition(double))); }