Kodi Community Forum

Full Version: Check OnPlayBackStarted() calls with an external player
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. Cool

The trakt.tv addon is broken with XBMC 13.0 (Gotham) and an external player (MPC-HC in my case).

It seems that the python function "onPlayBackStarted(self)" of the trakt addon in https://github.com/trakt/script.trakt/bl...service.py is never called.

So I tried digging into the logs, trakt python code and XBMC code.

What I've found :

The first difference for the trakt addon in the XBMC logs when it works :

XBMC Logs - Internal player (working) :
Code:
NOTICE: [trakt] [traktPlayer] onPlayBackStarted() - {u'item': {u'type': u'movie', u'id': 269, u'label': u'Welcome To The Jungle'}}

The trakt function "onPlayBackStarted(self)" in service.py in the trakt addon code is never called with the external player.

XBMC Logs - Internal player (working) :

Code:
DEBUG: CApplication::OnPlayBackStarted : play state was 1, starting 1
DEBUG: CApplication::PlayFile : OpenFile succeed, play state 2
DEBUG: CApplication::OnPlayBackStarted : play state was 2, starting 0
...
DEBUG: CApplication::OnPlayBackStopped : play state was 2, starting 0

XBMC Logs - External player (not working) :

Code:
DEBUG: CApplication::PlayFile : OpenFile succeed, play state 1
...
DEBUG: CApplication::OnPlayBackEnded : play state was 1, starting 0

It seems it corresponds to the XBMC function : "CApplication::OnPlayBackStarted()".
I found these "CApplication::OnPlayBack*" XBMC functions in https://github.com/xbmc/xbmc/blob/master...cation.cpp.

Code:
void CApplication::OnPlayBackEnded()
void CApplication::OnPlayBackStarted()
void CApplication::OnPlayBackStopped()
...
+ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)

These "CApplication::OnPlayBack*" functions have a python call in their code.

The calls of "OnPlayBackStarted()", "OnPlayBackStopped()" and "OnPlayBackEnded()" are all only made once and in a switch on "m_ePlayState".

XBMC code - Application.cpp :
Code:
// play state: none, starting; playing; stopped; ended.
// last 3 states are set by playback callback, they are all ignored during starting,
// but we recorded the state, here we can make up the callback for the state.
CLog::Log(LOGDEBUG,"%s : OpenFile succeed, play state %d", __FUNCTION__, m_ePlayState);
switch (m_ePlayState)
{
      case PLAY_STATE_PLAYING:
        OnPlayBackStarted();
        break;
      // FIXME: it seems no meaning to callback started here if there was an started callback
      //        before this stopped/ended callback we recorded. if we callback started here
      //        first, it will delay send OnPlay announce, but then we callback stopped/ended
      //        which will send OnStop announce at once, so currently, just call stopped/ended.
      case PLAY_STATE_ENDED:
        OnPlayBackEnded();
        break;
      case PLAY_STATE_STOPPED:
        OnPlayBackStopped();
        break;
      case PLAY_STATE_STARTING:
        // neither started nor stopped/ended callback be called, that means the item still
        // not started, we need not make up any callback, just leave this and
        // let the player callback do its work.
        break;
      default:
        break;
}

Here more informations and XBMC + trakt in debug logs :
http://forum.xbmc.org/showthread.php?tid...pid1719543
http://forum.xbmc.org/showthread.php?tid...pid1720497

The fault to the XBMC code in https://github.com/xbmc/xbmc/blob/master...cation.cpp ?

I don't know if it's a problem with the addon or with XBMC now...

Hope someone can finally help and solve this problem. I'm not a dev, sorry.

Contact me if you need more informations. Wink

Cheers.
(2014-05-29, 17:30)Ben91 Wrote: [ -> ]I'm not a dev, sorry.
Not a dev? So why post in:
Quote:Developer forums for XBMC related development, for programmers and coders only.

Moving it were it belongs.
@ Martijn : Thanks for being so nice.

Up.
I believe vdrfan fixed this in master already, no?
(2014-06-22, 00:44)jmarshall Wrote: [ -> ]I believe vdrfan fixed this in master already, no?

Wahou. Thank you for your fast answer !

But where did you get this information / saw this fix ? I tried looking for this on github, looked for vdrfan but I found nothing.

I'm interested to see what has been fixed and how. Also I would happy to test the XBMC Nightly builds if a patch has been pushed.
OK guys.

Good news.

I just tested XBMCSetup-20140702-ef3ac86-master (the last nightly build of 02.07.2014), and it seems the problem has been fixed !

The scrobbling & watched flag worked perfectly the first time. So it seems the code has been corrected.

Will check with movies later. Always had issues for scrobbling and sync watched flag. Will see.

Cheers.

PS : @ jmarshall or other, I'm still looking for the code fix. Any infos or links ? Thank you very much !