Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37423498
en ru br
Репозитории ALT

Группа :: Видео
Пакет: kde5-kaffeine

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: fix-playing-audiocd.patch
Скачать


diff -ruN kde5-kaffeine/src/backend-vlc/vlcmediawidget.cpp new_kde5-kaffeine/src/backend-vlc/vlcmediawidget.cpp
--- kde5-kaffeine/src/backend-vlc/vlcmediawidget.cpp	2018-10-09 15:26:53.090881299 +0300
+++ new_kde5-kaffeine/src/backend-vlc/vlcmediawidget.cpp	2018-10-09 16:15:50.742609547 +0300
@@ -27,6 +27,7 @@
 #include <QMap>
 #include <vlc/vlc.h>
 #include <vlc/libvlc_version.h>
+#include <unistd.h>
 
 #include "../configuration.h"
 #include "vlcmediawidget.h"
@@ -279,6 +280,9 @@
 	QByteArray url = source.getUrl().toEncoded();
 	playingDvd = false;
 
+	trackNumber = 1;
+	numDevType = 0;
+
 	switch (source.getType()) {
 	case MediaSource::Url:
 		if (url.endsWith(".iso")) {
@@ -287,6 +291,8 @@
 
 		break;
 	case MediaSource::AudioCd:
+		numDevType=2;
+
 		if (url.size() >= 7) {
 			url.replace(0, 4, "cdda");
 		} else {
@@ -315,11 +321,24 @@
 		break;
 	}
 
-	libvlc_media_t *vlcMedia = libvlc_media_new_location(vlcInstance, url.constData());
+	typeOfDevice = url.constData();
+
+	vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
+	if (numDevType == 2)
+		libvlc_media_add_option(vlcMedia, "cdda-track=1");
+
+	makePlay();
+
+	setCursor(Qt::BlankCursor);
+	setCursor(Qt::ArrowCursor);
+	timer->start(1000);
+	setMouseTracking(true);
+}
 
+void VlcMediaWidget::makePlay()
+{
 	if (vlcMedia == NULL) {
 		libvlc_media_player_stop(vlcMediaPlayer);
-		qCWarning(logMediaWidget, "Cannot create media %s", qPrintable(source.getUrl().toDisplayString()));
 		return;
 	}
 
@@ -335,24 +354,46 @@
 	libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
 	libvlc_media_release(vlcMedia);
 
-//	FIXME! subtitleUrl is only available for MediaSourceUrl private class
-//	if (source.subtitleUrl.isValid())
-//		setExternalSubtitle(source.subtitleUrl);
+	if (libvlc_media_player_play(vlcMediaPlayer) != 0)
+		return;
+}
 
-	if (libvlc_media_player_play(vlcMediaPlayer) != 0) {
-		qCWarning(logMediaWidget, "Cannot play media %s", qPrintable(source.getUrl().toDisplayString()));
-	}
+void VlcMediaWidget::playDirection(int direction)
+{
+	char numBuff[256];
+	char strBuff[512] = "cdda-track=";
 
-	setCursor(Qt::BlankCursor);
-	setCursor(Qt::ArrowCursor);
-	timer->start(1000);
-	setMouseTracking(true);
+	if (direction == -1)
+		trackNumber--;
+	else
+		trackNumber++;
+
+	sprintf(numBuff, "%d", trackNumber);
+	strcat(strBuff, numBuff);
+
+	if (vlcMedia != NULL)
+		libvlc_media_release(vlcMedia);
+
+    vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
+    libvlc_media_add_option(vlcMedia, strBuff);
+
+	makePlay();
+
+	sleep(1);
+
+	int playerState = libvlc_media_player_get_state(vlcMediaPlayer);
+
+	if (playerState != libvlc_Playing)
+		stop();
 }
 
 void VlcMediaWidget::stop()
 {
 	libvlc_media_player_stop(vlcMediaPlayer);
 
+	if (trackNumber != 1)
+		trackNumber = 1;
+
 	timer->stop();
 	setCursor(Qt::BlankCursor);
 	setCursor(Qt::ArrowCursor);
@@ -452,7 +493,10 @@
 {
 	int currentTitle = libvlc_media_player_get_title(vlcMediaPlayer);
 	int currentChapter = libvlc_media_player_get_chapter(vlcMediaPlayer);
-	libvlc_media_player_previous_chapter(vlcMediaPlayer);
+	if (numDevType == 2)
+		playDirection(-1);
+	else
+		libvlc_media_player_previous_chapter(vlcMediaPlayer);
 
 	if ((libvlc_media_player_get_title(vlcMediaPlayer) != currentTitle) ||
 	    (libvlc_media_player_get_chapter(vlcMediaPlayer) != currentChapter)) {
@@ -466,7 +510,10 @@
 {
 	int currentTitle = libvlc_media_player_get_title(vlcMediaPlayer);
 	int currentChapter = libvlc_media_player_get_chapter(vlcMediaPlayer);
-	libvlc_media_player_next_chapter(vlcMediaPlayer);
+	if (numDevType == 2)
+		playDirection(1);
+	else
+		libvlc_media_player_next_chapter(vlcMediaPlayer);
 
 	if ((libvlc_media_player_get_title(vlcMediaPlayer) != currentTitle) ||
 	    (libvlc_media_player_get_chapter(vlcMediaPlayer) != currentChapter)) {
@@ -507,6 +554,8 @@
 		playbackStatus = MediaWidget::Paused;
 		break;
 	case libvlc_Ended:
+		playDirection(1);
+		break;
 	case libvlc_Error:
 		playbackStatus = MediaWidget::Idle;
 		// don't keep last picture shown
diff -ruN kde5-kaffeine/src/backend-vlc/vlcmediawidget.h new_kde5-kaffeine/src/backend-vlc/vlcmediawidget.h
--- kde5-kaffeine/src/backend-vlc/vlcmediawidget.h	2018-10-09 15:26:53.090881299 +0300
+++ new_kde5-kaffeine/src/backend-vlc/vlcmediawidget.h	2018-10-09 15:36:22.707828605 +0300
@@ -25,6 +25,7 @@
 
 class libvlc_event_t;
 class libvlc_instance_t;
+class libvlc_media_t;
 class libvlc_media_player_t;
 class QTimer;
 
@@ -68,6 +69,8 @@
 	bool jumpToNextChapter();
 	void showDvdMenu();
 	void dvdNavigate(int key);
+	void playDirection(int direction);
+	void makePlay();
 
 	int updatePlaybackStatus();
 	void updateCurrentTotalTime();
@@ -90,10 +93,14 @@
 	static void vlcEventHandler(const libvlc_event_t *event, void *instance);
 
 	libvlc_instance_t *vlcInstance;
+	libvlc_media_t *vlcMedia;
 	libvlc_media_player_t *vlcMediaPlayer;
 	bool playingDvd;
 	bool mouseVisible;
 	QMap<int, int> subtitleId;
+    QByteArray typeOfDevice;
+    int numDevType;
+    int trackNumber = 1;
 };
 
 #endif /* VLCMEDIAWIDGET_H */
diff -ruN kde5-kaffeine/src/mediawidget.cpp new_kde5-kaffeine/src/mediawidget.cpp
--- kde5-kaffeine/src/mediawidget.cpp	2018-10-09 15:26:53.090881299 +0300
+++ new_kde5-kaffeine/src/mediawidget.cpp	2018-10-09 15:36:44.336826604 +0300
@@ -793,14 +793,14 @@
 {
 	if (source->getType() == MediaSource::Url)
 		emit playlistPrevious();
-	source->previous();
+	backend->jumpToPreviousChapter();
 }
 
 void MediaWidget::next()
 {
 	if (source->getType() == MediaSource::Url)
 		emit playlistNext();
-	source->next();
+	backend->jumpToNextChapter();
 }
 
 void MediaWidget::stop()
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin