Esempio n. 1
0
MusicPlayer::MusicPlayer(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MusicPlayer)
{
    ui->setupUi(this);

    Player = new QMediaPlayer(this);
    PlayList = new QMediaPlaylist;

    connect(Player,SIGNAL(positionChanged(qint64)),this,SLOT(PositionChanged(qint64)));
    connect(ui->LengthSlider,SIGNAL(sliderMoved(int)),this,SLOT(SetPosition(int)));
    connect(Player,SIGNAL(durationChanged(qint64)),this,SLOT(DurationChanged(qint64)));
    connect(Player,SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),this,SLOT(StatusChanged(QMediaPlayer::MediaStatus)));
    connect(ui->VolumeSlider,SIGNAL(valueChanged(int)),this,SLOT(SetVolume(int)));

    connect(ui->button_start,SIGNAL(released()),this,SLOT(Play()));
    connect(ui->button_stop,SIGNAL(released()),this,SLOT(Stop()));

    connect(ui->button_next,SIGNAL(released()),this,SLOT(Next()));
    connect(ui->button_prev,SIGNAL(released()),this,SLOT(Prev()));

    connect(ui->button_add,SIGNAL(released()),this,SLOT(Add()));
    connect(ui->button_remove,SIGNAL(released()),this,SLOT(Remove()));

    connect(ui->playlist,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(PlaySelected(QModelIndex)));

    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(SavePlayList()));
    connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(OpenPlayList()));

    Player->setPlaylist(PlayList);

    ui->VolumeSlider->setRange(0,100);
    ui->VolumeSlider->setValue(100);
}
// MessageReceived
void
PlaylistPlaybackManager::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_PLAYLIST_ITEM_ADDED:
//			printf("MSG_PLAYLIST_ITEM_ADDED\n");
			break;
		case MSG_PLAYLIST_ITEM_REMOVED:
//			printf("MSG_PLAYLIST_ITEM_REMOVED\n");
			break;
		case MSG_PLAYLIST_DURATION_CHANGED:
//			printf("MSG_PLAYLIST_DURATION_CHANGED\n");
			DurationChanged();
			break;

		default:
			NodeManager::MessageReceived(message);
			break;
	}
}
// SetPlaylist
void
PlaylistPlaybackManager::SetPlaylist(Playlist* playlist)
{
	if (fPlaylist == playlist)
		return;

	if (fPlaylist)
		fPlaylist->RemoveListObserver(&fPlaylistObserver);

	fPlaylist = playlist;

	if (fVideoSupplier)
		fVideoSupplier->SetPlaylist(playlist);
	if (fAudioSupplier)
		fAudioSupplier->SetPlaylist(playlist);

	if (fPlaylist)
		fPlaylist->AddListObserver(&fPlaylistObserver);

	DurationChanged();
}
Esempio n. 4
0
void
MediaSourceDecoder::ScheduleDurationChange(double aOldDuration,
                                           double aNewDuration,
                                           MSRangeRemovalAction aAction)
{
  if (aAction == MSRangeRemovalAction::SKIP) {
    if (NS_IsMainThread()) {
      MediaDecoder::DurationChanged();
    } else {
      nsCOMPtr<nsIRunnable> task =
        NS_NewRunnableMethod(this, &MediaDecoder::DurationChanged);
      NS_DispatchToMainThread(task);
    }
  } else {
    if (NS_IsMainThread()) {
      DurationChanged(aOldDuration, aNewDuration);
    } else {
      nsCOMPtr<nsIRunnable> task =
        new DurationChangedRunnable(this, aOldDuration, aNewDuration);
      NS_DispatchToMainThread(task);
    }
  }
}