Skip to content

Commit

Permalink
Merge pull request #9399 from b-pass/comm-skip-toggle
Browse files Browse the repository at this point in the history
Commercial skipping notifications and toggle action
  • Loading branch information
FernetMenta committed Mar 20, 2016
2 parents 07741ab + 1b2c8e0 commit c2afc63
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
17 changes: 16 additions & 1 deletion addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -14327,7 +14327,22 @@ msgctxt "#25010"
msgid "Chapter %u"
msgstr ""

#empty strings from id 25011 to 29800
#: xbmc/cores/VideoPlayer/VideoPlayer.cpp
msgctxt "#25011"
msgid "Commercial"
msgstr ""

#: xbmc/cores/VideoPlayer/VideoPlayer.cpp
msgctxt "#25012"
msgid "Auto-skip off"
msgstr ""

#: xbmc/cores/VideoPlayer/VideoPlayer.cpp
msgctxt "#25013"
msgid "Auto-skip on"
msgstr ""

#empty strings from id 25014 to 29800

#: unused
msgctxt "#29801"
Expand Down
50 changes: 38 additions & 12 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Expand Up @@ -659,6 +659,8 @@ CVideoPlayer::CVideoPlayer(IPlayerCallback& callback)
m_omxplayer_mode = false;
#endif

m_SkipCommercials = true;

m_processInfo = CProcessInfo::CreateInstance();
CreatePlayers();

Expand Down Expand Up @@ -1255,13 +1257,24 @@ void CVideoPlayer::Process()
}
CLog::Log(LOGDEBUG, "%s - Start position set to last stopped position: %d", __FUNCTION__, starttime);
}
else if(m_Edl.InCut(0, &cut)
&& (cut.action == CEdl::CUT || cut.action == CEdl::COMM_BREAK))
else if(m_Edl.InCut(0, &cut))
{
starttime = cut.end;
CLog::Log(LOGDEBUG, "%s - Start position set to end of first cut or commercial break: %d", __FUNCTION__, starttime);
if(cut.action == CEdl::COMM_BREAK)
if (cut.action == CEdl::CUT)
{
starttime = cut.end;
CLog::Log(LOGDEBUG, "%s - Start position set to end of first cut: %d", __FUNCTION__, starttime);
}
else if (cut.action == CEdl::COMM_BREAK)
{
if (m_SkipCommercials)
{
starttime = cut.end;
CLog::Log(LOGDEBUG, "%s - Start position set to end of first commercial break: %d", __FUNCTION__, starttime);
}

std::string strTimeString = StringUtils::SecondsToTimeString(cut.end / 1000, TIME_FORMAT_MM_SS);
CGUIDialogKaiToast::QueueNotification(g_localizeStrings.Get(25011), strTimeString);

/*
* Setup auto skip markers as if the commercial break had been skipped using standard
* detection.
Expand Down Expand Up @@ -2299,13 +2312,21 @@ void CVideoPlayer::CheckAutoSceneSkip()
&& GetPlaySpeed() >= 0
&& cut.start > m_EdlAutoSkipMarkers.commbreak_end)
{
CLog::Log(LOGDEBUG, "%s - Clock in commercial break [%s - %s]: %s. Automatically skipping to end of commercial break (only done once per break)",
__FUNCTION__, CEdl::MillisecondsToTimeString(cut.start).c_str(), CEdl::MillisecondsToTimeString(cut.end).c_str(),
CEdl::MillisecondsToTimeString(clock).c_str());
/*
* Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
*/
m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, false, m_omxplayer_mode, true, false, true));
std::string strTimeString = StringUtils::SecondsToTimeString((cut.end - cut.start) / 1000, TIME_FORMAT_MM_SS);
CGUIDialogKaiToast::QueueNotification(g_localizeStrings.Get(25011), strTimeString);

if (m_SkipCommercials)
{
CLog::Log(LOGDEBUG, "%s - Clock in commercial break [%s - %s]: %s. Automatically skipping to end of commercial break (only done once per break)",
__FUNCTION__, CEdl::MillisecondsToTimeString(cut.start).c_str(), CEdl::MillisecondsToTimeString(cut.end).c_str(),
CEdl::MillisecondsToTimeString(clock).c_str());

/*
* Seeking is NOT flushed so any content up to the demux point is retained when playing forwards.
*/
m_messenger.Put(new CDVDMsgPlayerSeek(cut.end + 1, true, false, m_omxplayer_mode, true, false, true));
}

/*
* Each commercial break is only skipped once so poorly detected commercial breaks can be
* manually re-entered. Start and end are recorded to prevent looping and to allow seeking back
Expand Down Expand Up @@ -4391,6 +4412,11 @@ bool CVideoPlayer::OnAction(const CAction &action)
}
else
break;
case ACTION_TOGGLE_COMMSKIP:
m_SkipCommercials = !m_SkipCommercials;
CGUIDialogKaiToast::QueueNotification(g_localizeStrings.Get(25011),
g_localizeStrings.Get(m_SkipCommercials ? 25013 : 25012));
break;
case ACTION_SHOW_CODEC:
m_renderManager.ToggleDebug();
break;
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/VideoPlayer.h
Expand Up @@ -526,6 +526,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
CEvent m_ready;

CEdl m_Edl;
bool m_SkipCommercials;

struct SEdlAutoSkipMarkers {

Expand Down
1 change: 1 addition & 0 deletions xbmc/input/ButtonTranslator.cpp
Expand Up @@ -236,6 +236,7 @@ static const ActionMapping actions[] =
{ "playpvrtv" , ACTION_PVR_PLAY_TV },
{ "playpvrradio" , ACTION_PVR_PLAY_RADIO },
{ "record" , ACTION_RECORD },
{ "togglecommskip" , ACTION_TOGGLE_COMMSKIP },

// Mouse actions
{ "leftclick" , ACTION_MOUSE_LEFT_CLICK },
Expand Down
1 change: 1 addition & 0 deletions xbmc/input/Key.h
Expand Up @@ -384,6 +384,7 @@
#define ACTION_TRIGGER_OSD 243 //!< show autoclosing OSD. Can b used in videoFullScreen.xml window id=2005
#define ACTION_INPUT_TEXT 244
#define ACTION_VOLUME_SET 245
#define ACTION_TOGGLE_COMMSKIP 246

#define ACTION_TOUCH_TAP 401 //!< touch actions
#define ACTION_TOUCH_TAP_TEN 410 //!< touch actions
Expand Down

0 comments on commit c2afc63

Please sign in to comment.