diff options
Diffstat (limited to 'src/core.cpp')
-rw-r--r-- | src/core.cpp | 133 |
1 files changed, 25 insertions, 108 deletions
diff --git a/src/core.cpp b/src/core.cpp index 74d73dc..b27e492 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2015 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -682,7 +682,6 @@ void Core::openDVD(int title) { mset.reset(); mset.current_title_id = title; - mset.current_chapter_id = 1; mset.current_angle_id = 1; initializeMenus(); @@ -712,7 +711,6 @@ void Core::openVCD(int title) { mset.reset(); mset.current_title_id = title; - mset.current_chapter_id = -1; mset.current_angle_id = -1; /* initializeMenus(); */ @@ -741,7 +739,6 @@ void Core::openAudioCD(int title) { mset.reset(); mset.current_title_id = title; - mset.current_chapter_id = -1; mset.current_angle_id = -1; /* initializeMenus(); */ @@ -789,7 +786,6 @@ void Core::openDVD(QString dvd_url) { mset.reset(); mset.current_title_id = title; - mset.current_chapter_id = firstChapter(); mset.current_angle_id = 1; /* initializeMenus(); */ @@ -838,7 +834,6 @@ void Core::openBluRay(QString bluray_url) { mset.reset(); mset.current_title_id = title; - mset.current_chapter_id = firstChapter(); mset.current_angle_id = 1; /* initializeMenus(); */ @@ -1116,11 +1111,6 @@ void Core::newMediaPlaying() { } #endif - if (mdat.n_chapters > 0) { - // Just to show the first chapter checked in the menu - mset.current_chapter_id = firstChapter(); - } - mdat.initialized = true; // MPlayer doesn't display the length in ID_LENGTH for audio CDs... @@ -1578,15 +1568,7 @@ void Core::startMplayer( QString file, double seek ) { proc->clearArguments(); // Set the screenshot directory - #ifdef Q_OS_WIN - if (pref->use_short_pathnames) { - proc->setScreenshotDirectory(Helper::shortPathName(pref->screenshot_directory)); - } - else - #endif - { - proc->setScreenshotDirectory(pref->screenshot_directory); - } + /* deleted (done later) */ // Use absolute path, otherwise after changing to the screenshot directory // the mplayer path might not be found if it's a relative path @@ -1705,10 +1687,6 @@ void Core::startMplayer( QString file, double seek ) { proc->setOption("sub-fuzziness", pref->subfuzziness); - // From mplayer SVN r27667 the number of chapters can be obtained from ID_CHAPTERS - mset.current_chapter_id = 0; // Reset chapters - // TODO: I think the current_chapter_id thing has to be deleted - if (pref->vo != "player_default") { if (!pref->vo.isEmpty()) { proc->setOption("vo", pref->vo ); @@ -2071,15 +2049,6 @@ void Core::startMplayer( QString file, double seek ) { } } - /* - if (mset.current_chapter_id > 0) { - int chapter = mset.current_chapter_id; - // Fix for older versions of mplayer: - if ((mdat.type == TYPE_DVD) && (firstChapter() == 0)) chapter++; - proc->setOption("chapter", QString::number(chapter)); - } - */ - if (mset.current_angle_id > 0) { proc->setOption("dvdangle", QString::number( mset.current_angle_id)); } @@ -2289,25 +2258,29 @@ void Core::startMplayer( QString file, double seek ) { } // Screenshots - if (screenshot_enabled) { - proc->addVF("screenshot"); + #ifdef MPLAYER_SUPPORT + if (screenshot_enabled && proc->isMPlayer()) { + QString dir = pref->screenshot_directory; + #ifdef Q_OS_WIN + if (pref->use_short_pathnames) dir = Helper::shortPathName(pref->screenshot_directory); + #endif + proc->enableScreenshots(dir); } + #endif #ifndef Q_OS_WIN end_video_filters: #endif -#ifdef MPV_SUPPORT - // Template for screenshots (only works with mpv) - if (screenshot_enabled) { - if (!pref->screenshot_template.isEmpty()) { - proc->setOption("screenshot_template", pref->screenshot_template); - } - if (!pref->screenshot_format.isEmpty()) { - proc->setOption("screenshot_format", pref->screenshot_format); - } + #ifdef MPV_SUPPORT + if (screenshot_enabled && proc->isMPV()) { + QString dir = pref->screenshot_directory; + #ifdef Q_OS_WIN + if (pref->use_short_pathnames) dir = Helper::shortPathName(pref->screenshot_directory); + #endif + proc->enableScreenshots(dir, pref->screenshot_template, pref->screenshot_format); } -#endif + #endif // slices if ((pref->use_slices) && (!force_noslices)) { @@ -2475,9 +2448,12 @@ void Core::startMplayer( QString file, double seek ) { } #endif +#ifdef MPLAYER_SUPPORT if (proc->isMPlayer()) { proc->setMedia(file, pref->use_playlist_option ? url_is_playlist : false); - } else { + } else +#endif + { proc->setMedia(file, false); // Don't use playlist with mpv } @@ -3831,39 +3807,7 @@ void Core::changeTitle(int ID) { void Core::changeChapter(int ID) { qDebug("Core::changeChapter: ID: %d", ID); - - if (mdat.type != TYPE_DVD) { - /* - if (mdat.chapters.find(ID) > -1) { - double start = mdat.chapters.item(ID).start(); - qDebug("Core::changeChapter: start: %f", start); - goToSec(start); - mset.current_chapter_id = ID; - } else { - */ - proc->setChapter(ID); - mset.current_chapter_id = ID; - //updateWidgets(); - /* - } - */ - } else { -#if SMART_DVD_CHAPTERS - if (pref->cache_for_dvds == 0) { -#else - if (pref->fast_chapter_change) { -#endif - proc->setChapter(ID); - mset.current_chapter_id = ID; - updateWidgets(); - } else { - stopMplayer(); - mset.current_chapter_id = ID; - //goToPos(0); - mset.current_sec = 0; - restartPlay(); - } - } + proc->setChapter(ID); } int Core::firstChapter() { @@ -3892,39 +3836,12 @@ int Core::firstBlurayTitle() { void Core::prevChapter() { qDebug("Core::prevChapter"); - - int last_chapter = 0; - int first_chapter = firstChapter(); - - int ID = mdat.chapters.itemBeforeTime(mset.current_sec).ID(); - - if (ID == -1) { - last_chapter = mdat.n_chapters + firstChapter() - 1; - - ID = mset.current_chapter_id - 1; - if (ID < first_chapter) { - ID = last_chapter; - } - } - - changeChapter(ID); + proc->previousChapter(); } void Core::nextChapter() { qDebug("Core::nextChapter"); - - int last_chapter = mdat.n_chapters + firstChapter() - 1; - - int ID = mdat.chapters.itemAfterTime(mset.current_sec).ID(); - - if (ID == -1) { - ID = mset.current_chapter_id + 1; - if (ID > last_chapter) { - ID = firstChapter(); - } - } - - changeChapter(ID); + proc->nextChapter(); } void Core::changeAngle(int ID) { |