summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Tinkl <[email protected]>2014-12-01 00:46:55 +0100
committerLukáš Tinkl <[email protected]>2014-12-01 00:46:55 +0100
commit2574858350d74cc06bbc9dabc4c6db8c56181099 (patch)
tree388e67ad6c4070910fcd7cc4377d94662081a84d
parent89750bbe3f8a361032051261388b1ab94fb7f695 (diff)
fix playing audio CDs
-rw-r--r--src/app/main.cpp1
-rw-r--r--src/app/mainWindow.cpp4
-rw-r--r--src/app/playerApplication.cpp1
-rw-r--r--src/app/stateChange.cpp1
-rw-r--r--src/app/theStream.cpp74
-rw-r--r--src/app/theStream.h67
-rw-r--r--src/app/videoWindow.cpp25
-rw-r--r--src/app/videoWindow.h3
-rw-r--r--src/mpris2/mediaplayer2player.cpp4
9 files changed, 73 insertions, 107 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 4ba5cdb..5bab2bf 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -1,6 +1,7 @@
/***********************************************************************
* Copyright 2004 Max Howell <[email protected]>
* 2007 Ian Monroe <[email protected]>
+ * Copyright 2014 Lukáš Tinkl <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/src/app/mainWindow.cpp b/src/app/mainWindow.cpp
index 0f5ffbf..64d3b68 100644
--- a/src/app/mainWindow.cpp
+++ b/src/app/mainWindow.cpp
@@ -345,13 +345,13 @@ MainWindow::setupActions()
connect( uniqueToggle, SIGNAL(toggled(bool)), this, SLOT(toggleUnique(bool)) );
addToAc( uniqueToggle )
- QAction* prev_chapter = new QAction( QIcon::fromTheme(QLatin1String( "media-skip-backward" )), i18n("Previous Chapter"), ac );
+ QAction* prev_chapter = new QAction( QIcon::fromTheme(QLatin1String( "media-skip-backward" )), i18n("Previous"), ac );
prev_chapter->setObjectName( QLatin1String( "prev_chapter" ) );
ac->setDefaultShortcut(prev_chapter, Qt::Key_Comma);
connect( prev_chapter, SIGNAL(triggered()), engine(), SLOT(prevChapter()) );
addToAc( prev_chapter )
- QAction* next_chapter = new QAction( QIcon::fromTheme(QLatin1String( "media-skip-forward" )), i18n("Next Chapter"), ac );
+ QAction* next_chapter = new QAction( QIcon::fromTheme(QLatin1String( "media-skip-forward" )), i18n("Next"), ac );
next_chapter->setObjectName( QLatin1String( "next_chapter" ) );
ac->setDefaultShortcut(next_chapter, Qt::Key_Period);
connect( next_chapter, SIGNAL(triggered()), engine(), SLOT(nextChapter()) );
diff --git a/src/app/playerApplication.cpp b/src/app/playerApplication.cpp
index 96b361c..4f5fb44 100644
--- a/src/app/playerApplication.cpp
+++ b/src/app/playerApplication.cpp
@@ -1,5 +1,6 @@
/***********************************************************************
* Copyright 2011 Geoffry Song <[email protected]>
+ * Copyright 2014 Lukáš Tinkl <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
diff --git a/src/app/stateChange.cpp b/src/app/stateChange.cpp
index a73e264..7bfd54f 100644
--- a/src/app/stateChange.cpp
+++ b/src/app/stateChange.cpp
@@ -159,6 +159,7 @@ void MainWindow::engineSeekableChanged(bool canSeek)
void MainWindow::engineMetaDataChanged()
{
qDebug() << "metaDataChanged"; // FIXME Phonon emits metadataChanged() too often :/
+ qDebug() << "Disc ID:" << TheStream::discId();
updateTitleBarText();
if (!TheStream::hasVideo())
m_audioView->update();
diff --git a/src/app/theStream.cpp b/src/app/theStream.cpp
index 58a2dd2..4aa69d8 100644
--- a/src/app/theStream.cpp
+++ b/src/app/theStream.cpp
@@ -192,74 +192,16 @@ TheStream::metaData(Phonon::MetaData key)
{
QStringList values = videoWindow()->m_media->metaData(key);
qDebug() << values;
- return (values.isEmpty()) ? QString() : values.join(QString(QLatin1Char( ' ' )));
+ return (values.isEmpty()) ? QString() : values.join(QLatin1Char( ' ' ));
}
+QString TheStream::discId()
+{
+ QStringList values = videoWindow()->m_media->metaData(Phonon::MusicBrainzDiscIdMetaData);
+ if (!values.isEmpty())
+ return values.first();
-/*
- static inline QString
- entryHelper( const QString &plate, const QString &s1, const QString &s2 )
- {
- return s2.isEmpty() ? s2 : plate.arg( s1 ).arg( s2 );
- }
-
- static inline QString
- sectionHelper( const QString &sectionTitle, const QStringList &entries )
- {
- QString s;
-
- foreach( const QString& str, entries )
- if( !str.isEmpty() )
- s += str;
-
- return s.isEmpty() ? s : "<h2>" + sectionTitle + "</h2>" + s;
- }
+ return QString();
+}
- QString
- TheStream::information()
- {
- return QString();
-// #define meta( x ) xine_get_meta_info( VideoWindow::s_instance->m_stream, x )
-// #define info( x, y ) x.arg( xine_get_stream_info( VideoWindow::s_instance->m_stream, y ) )
-// #define simple( x ) QString::number( xine_get_stream_info( VideoWindow::s_instance->m_stream, x ) )
-//
-// const QString plate = "<p><b>%1</b>: %2</p>";
-// QString s;
-//
-// s += sectionHelper( i18n("Metadata"),
-// QStringList()
-// << entryHelper( plate, i18n("Title"), meta( XINE_META_INFO_TITLE ) )
-// << entryHelper( plate, i18n("Comment"), meta( XINE_META_INFO_COMMENT ) )
-// << entryHelper( plate, i18n("Artist"), meta( XINE_META_INFO_ARTIST ) )
-// << entryHelper( plate, i18n("Genre"), meta( XINE_META_INFO_GENRE ) )
-// << entryHelper( plate, i18n("Album"), meta( XINE_META_INFO_ALBUM ) )
-// << entryHelper( plate, i18n("Year"), meta( XINE_META_INFO_YEAR ) ) );
-//
-// s += sectionHelper( i18n("Audio Properties"),
-// QStringList()
-// << entryHelper( plate, i18n("Bitrate"), info( i18n("%1 bps"), XINE_STREAM_INFO_AUDIO_BITRATE ) )
-// << entryHelper( plate, i18n("Sample-rate"), info( i18n("%1 Hz"), XINE_STREAM_INFO_AUDIO_SAMPLERATE ) ) );
-//
-// s += sectionHelper( i18n("Technical Information"),
-// QStringList()
-// << entryHelper( plate, i18n("Video Codec"), meta( XINE_META_INFO_VIDEOCODEC ) )
-// << entryHelper( plate, i18n("Audio Codec"), meta( XINE_META_INFO_AUDIOCODEC ) )
-// << entryHelper( plate, i18n("System Layer"), meta( XINE_META_INFO_SYSTEMLAYER ) )
-// << entryHelper( plate, i18n("Input Plugin"), meta( XINE_META_INFO_INPUT_PLUGIN ))
-// << entryHelper( plate, i18n("CDINDEX_DISCID"), meta( XINE_META_INFO_CDINDEX_DISCID ) ) );
-//
-// QStringList texts;
-// texts << "BITRATE" << "SEEKABLE" << "VIDEO_WIDTH" << "VIDEO_HEIGHT" << "VIDEO_RATIO" << "VIDEO_CHANNELS" << "VIDEO_STREAMS" << "VIDEO_BITRATE" << "VIDEO_FOURCC" << "VIDEO_HANDLED" << "FRAME_DURATION" << "AUDIO_CHANNELS" << "AUDIO_BITS" << "-AUDIO_SAMPLERATE" << "-AUDIO_BITRATE" << "AUDIO_FOURCC" << "AUDIO_HANDLED" << "HAS_CHAPTERS" << "HAS_VIDEO" << "HAS_AUDIO" << "-IGNORE_VIDEO" << "-IGNORE_AUDIO" << "-IGNORE_SPU" << "VIDEO_HAS_STILL" << "MAX_AUDIO_CHANNEL" << "MAX_SPU_CHANNEL" << "AUDIO_MODE" << "SKIPPED_FRAMES" << "DISCARDED_FRAMES";
-//
-// s += "<h2>Other</h2>";
-// for( uint x = 0; x <= 28; ++x )
-// s += entryHelper( plate, texts[x], simple( x ) );
-//
-// #undef meta
-// #undef info
-// #undef simple
-//
-// return s;
- }
-*/
}
diff --git a/src/app/theStream.h b/src/app/theStream.h
index 32a5dbf..efa3ace 100644
--- a/src/app/theStream.h
+++ b/src/app/theStream.h
@@ -7,7 +7,7 @@
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
+ * by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
@@ -30,52 +30,53 @@
/// for purely static classes
#define DRAGONPLAYER_NO_EXPORT( T ) \
- T(); \
- ~T(); \
- T( const T& ); \
- T &operator=( const T& ); \
- bool operator==( const T& ); \
- bool operator!=( const T& );
+ T(); \
+ ~T(); \
+ T( const T& ); \
+ T &operator=( const T& ); \
+ bool operator==( const T& ); \
+ bool operator!=( const T& );
class QAction;
namespace Dragon
{
- class TheStream
- {
- DRAGONPLAYER_NO_EXPORT( TheStream )
+class TheStream
+{
+ DRAGONPLAYER_NO_EXPORT( TheStream )
+
+ public:
+ static QUrl url();
- public:
- static QUrl url();
+ static bool canSeek();
+ static bool hasAudio();
+ static bool hasVideo();
+ static bool hasMedia();
- static bool canSeek();
- static bool hasAudio();
- static bool hasVideo();
- static bool hasMedia();
+ static QSize defaultVideoSize();
- static QSize defaultVideoSize();
+ static int aspectRatio();
+ static QAction* aspectRatioAction();
+ static void setRatio( QAction* );
+ static void addRatio( int, QAction* );
- static int aspectRatio();
- static QAction* aspectRatioAction();
- static void setRatio( QAction* );
- static void addRatio( int, QAction* );
+ static const char* CHANNEL_PROPERTY;
+ static int subtitleChannel();
+ static int audioChannel();
- static const char* CHANNEL_PROPERTY;
- static int subtitleChannel();
- static int audioChannel();
+ static QString prettyTitle();
+ static QString fullTitle();
- static QString prettyTitle();
- static QString fullTitle();
+ static QString metaData(Phonon::MetaData key);
+ static QString discId();
- static QString metaData(Phonon::MetaData key);
-
- static bool hasProfile();
+ static bool hasProfile();
- static KConfigGroup profile();
- private:
- static QHash<int, QAction*> s_aspectRatioActions;
- };
+ static KConfigGroup profile();
+private:
+ static QHash<int, QAction*> s_aspectRatioActions;
+};
}
#endif
diff --git a/src/app/videoWindow.cpp b/src/app/videoWindow.cpp
index 3619e31..3a1d6c8 100644
--- a/src/app/videoWindow.cpp
+++ b/src/app/videoWindow.cpp
@@ -101,6 +101,7 @@ VideoWindow::VideoWindow( QWidget *parent )
m_aOutput = new AudioOutput( Phonon::VideoCategory, this );
m_media = new MediaObject( this );
m_controller = new MediaController( m_media );
+ m_controller->setAutoplayTitles(true);
Phonon::createPath(m_media, m_vWidget);
m_audioPath = Phonon::createPath(m_media, m_aOutput);
m_media->setTickInterval( 1000 );
@@ -182,7 +183,7 @@ VideoWindow::load(const QUrl &url )
QMimeType mimeType = db.mimeTypeForUrl(url);
qDebug() << "detected mimetype: " << mimeType.name();
if( mimeType.inherits( QLatin1String( "application/x-cd-image" ) ) || mimeType.inherits( QLatin1String( "inode/directory" ) ) )
- m_media->setCurrentSource( Phonon::MediaSource( Phonon::Dvd, url.path() ) ); // kf5 FIXME?
+ m_media->setCurrentSource( Phonon::MediaSource( Phonon::Dvd, url.path() ) );
else
m_media->setCurrentSource( url );
m_justLoaded = true;
@@ -637,13 +638,19 @@ VideoWindow::videoSetting( const QString& setting )
void
VideoWindow::prevChapter()
{
- m_controller->setCurrentChapter(m_controller->currentChapter() - 1);
+ if (TheStream::hasVideo())
+ m_controller->setCurrentChapter(m_controller->currentChapter() - 1);
+ else
+ m_controller->previousTitle();
}
void
VideoWindow::nextChapter()
{
- m_controller->setCurrentChapter(m_controller->currentChapter() + 1);
+ if (TheStream::hasVideo())
+ m_controller->setCurrentChapter(m_controller->currentChapter() + 1);
+ else
+ m_controller->nextTitle();
}
void
@@ -688,6 +695,16 @@ VideoWindow::decreaseVolume()
m_aOutput->setVolume(qMax(qreal(0.0), volume() - qreal(0.10)));
}
+bool VideoWindow::canGoPrev() const
+{
+ return m_controller->currentTitle() > 1;
+}
+
+bool VideoWindow::canGoNext() const
+{
+ return m_controller->currentTitle() < m_controller->availableTitles();
+}
+
///////////
///Protected
///////////
@@ -808,7 +825,7 @@ VideoWindow::eject()
}
}
- profile.writeEntry( "Date", QDate::currentDate().toString("dd/MM/yyyy") );
+ profile.writeEntry( "Date", QDate::currentDate() );
profile.sync();
}
diff --git a/src/app/videoWindow.h b/src/app/videoWindow.h
index fd1e64f..05b5725 100644
--- a/src/app/videoWindow.h
+++ b/src/app/videoWindow.h
@@ -155,6 +155,9 @@ public slots:
void increaseVolume();
void decreaseVolume();
+ bool canGoPrev() const;
+ bool canGoNext() const;
+
protected:
virtual bool event( QEvent* e ) Q_DECL_OVERRIDE;
virtual void contextMenuEvent( QContextMenuEvent * event ) Q_DECL_OVERRIDE;
diff --git a/src/mpris2/mediaplayer2player.cpp b/src/mpris2/mediaplayer2player.cpp
index aad08cc..b611360 100644
--- a/src/mpris2/mediaplayer2player.cpp
+++ b/src/mpris2/mediaplayer2player.cpp
@@ -49,7 +49,7 @@ MediaPlayer2Player::~MediaPlayer2Player()
bool MediaPlayer2Player::CanGoNext() const
{
- return false;
+ return Dragon::engine()->canGoNext();
}
void MediaPlayer2Player::Next() const
@@ -59,7 +59,7 @@ void MediaPlayer2Player::Next() const
bool MediaPlayer2Player::CanGoPrevious() const
{
- return false;
+ return Dragon::engine()->canGoPrev();
}
void MediaPlayer2Player::Previous() const