Release Artist Slideshow addon (with skin and addon integration)
(2013-09-06, 23:42)pkscuot Wrote:
(2013-09-05, 14:46)McMuzz4 Wrote: Thanks for offering your help with this issue, I've just learnt how to enable debug logging and have captured a log for you, so the skipping audio with AS + Spotimc problem can further be investigated (if it even is related to AS at all). I'm not sure if you've read the full discussion on the issue, but the gist is Spoticmc will begin repeatedly pausing and skipping commencing from the second song in any playlist if AS is also enabled, but the first song will always plays fine. If I disable AS no more skipping in Spotimc.

Here are my notes for each notable event that took place and should correspond to the debug log:
1) ~21:13:00 Boot into xbmc (xbmcbuntu) to begin debug log session.
2) ~21:15:15 Begin playing first song in Spotimc
3) ~21:16:15 I press TAB on keyboard to start artist slideshow visualisation
4) ~21:18:00 Artist info and slideshow images begin to populate the screen
5) ~21:19:10 First song ends and next song automatically starts playing.
6) ~21:19:20 Second song begins to repeatedly pause and play for 5 seconds each over and over.
7) ~21:21:00 I stop the song playback here, at which point it had still been repeatedly pausing and playing every 5 or so seconds each.
8) ~21:21:10 I exit out of Spotimc

I think this is going to be my day of offering nothing helpful. Sad

I looked through the debug log, and whatever issue is causing the playback to hickup is keeping AS from even logging anything that it is doing (which leads me to believe it isn't able to do anything). I do see a JSON call where AS is asking for the artist and MusicBrainz ID of the currently playing artist, but after that nothing until the next JSON request. I can tell that's the AS JSON request because of the data it asks for. So the only thing I can figure is that for some reason making the JSON request of XBMC somehow disrupts the Spotify stream in a way that causes the pausing. I can only assume it is not happening on the first song because the stream got started before AS was invoked. I guess on the second song there is some contention between the JSON call for the currently playing information and something else.

The bottom line here is that there likely isn't anything I can do to fix this, as the JSON call is absolutely critical to how AS functions.


Hi pkscuot,

Your statement is very untrue - your information was actually very, very helpful and drove me find motivation to explore to discover a solution and create a patch!! Big Grin

tl;dr: For some reason Spotimc doesn't like the many repeated JSON requests to the API (though i'm not sure why it only stutters beginning from playback of the second song) - I've posted my solution below.

long version:
After studying the debug log I determined that the pausing occurs exactly when the info is logged "CSoftAEStream::GetFrame - Underrun". Each time this occurred was shortly after a JSON query from artist slideshow that you mentioned. After a bit of googling i discovered that audio stutting + JSON queries could be related to a possible bug with Linux and AudioEngine: http://forum.xbmc.org/showthread.php?tid=147822 where large amounts of JSON queries cause stuttering. I'm still at a loss why the stuttering occurs only after the first song finishes - but anyway..

So I perform some testing:

My first test was I edited the Artist Slideshow python script to allow the first song play through then sleep the artist slideshow script when the second song starts for 10 to 40 seconds, just before the JSON request. This didn't result in anything positive it began stuttering/skipping when AS script finished sleeping.

My second test was to detect if a Spotify stream is playing and pause every second before the JSON query. This resulted in a little less stuttering, so i continued to adjusting until i found a sweet spot at 10 seconds to stop the songs stuttering/skipping. But this was frustrating because while it solved the problem it prevented AS from functioning nice and quickly and took a very long time for artist information to populate, sometimes not until a few songs of playback.

My third test which I have put below is my solution - it will detect if a new song is playing that is a Spotify stream, and if so it will perform the JSON call once and store the response value in a variable. It will then use the stored JSON response to query artist information and not won't call the JSON API again until a different song starts playing

My patch consists of the following, I made changes to two functions:

(btw I'm sure it could be done better I've never used python before - also sorry but I've never contributed to code before so apologies if I should be doing this differently)

At the end of def _init_vars( self ): I put the following lines:
Code:
    self.playing_file_last_value = -1
    self.response_last_value = ""

And I modified the first couple dozen lines of def _get_current_artists_info( self, type ):
Code:
def _get_current_artists_info( self, type ):
        featured_artists = ''
        artist_names = []
        artists_info = []
        mbids = []
        if( xbmc.Player().isPlayingAudio() == True ):
            # Grab currently playing music file and check if it is a Spotimc stream
            playing_file = xbmc.Player().getPlayingFile()
            if "X-Spotify-Token" in playing_file:
                # Check if a new track is playing by comparing the current song file name to the last playing song file name
                if playing_file != self.playing_file_last_value:
                    # wait 1 seconds for audio stream to begin
                    time.sleep(1)
                    log ( "Spotimc Detected: Limiting JSON calls to occur once per song to prevent audio stuttering/skipping" )
                    log ( "Playlist Position: %d " %(xbmc.PlayList(0).getposition()) )
                    # Perform JSON call
                    response = xbmc.executeJSONRPC ( '{"jsonrpc":"2.0", "method":"Player.GetItem", "params":{"playerid":0, "properties":["artist", "musicbrainzartistid"]},"id":1}' )
                    # store JSON response for continued usage
                    self.response_last_value = response
                    log ( "JSON response: " + response )
                    self.playing_file_last_value = playing_file
                # If still playing the same track, use the stored JSON response
                else:
                    response = self.response_last_value
            # If Spotimc not in use, normal operation
            else:    
                response = xbmc.executeJSONRPC ( '{"jsonrpc":"2.0", "method":"Player.GetItem", "params":{"playerid":0, "properties":["artist", "musicbrainzartistid"]},"id":1}' )
            try:
...
Reply


Messages In This Thread
New Test Version Available - by pkscout - 2012-03-08, 16:26
[No subject] - by mardup - 2012-03-10, 12:26
[No subject] - by pkscout - 2012-03-11, 01:35
RE: - by mardup - 2012-03-12, 17:50
RE: - by pkscout - 2012-03-13, 03:22
New Beta Version for Testing - by pkscout - 2012-07-13, 17:54
New Beta Version for Testing - by pkscout - 2012-07-14, 22:50
Pull Request for v1.4 Submitted - by pkscout - 2012-07-20, 23:01
New Beta Version for Testing - by pkscout - 2012-08-10, 03:18
New Frodo BETA Support Files - by pkscout - 2012-11-21, 06:20
RE: [RELEASE] Artist Slideshow 1.3.0 addon (with skin and addon integration) - by McMuzz4 - 2013-09-10, 13:07
New 2.0.0 Beta Coming Soon - by pkscout - 2016-05-12, 02:54
Writing tips - by Parkerbup - 2017-02-03, 14:56
Add-on Artist Slideshow - by jo26 - 2014-08-08, 22:58
Logout Mark Read Team Forum Stats Members Help
Artist Slideshow addon (with skin and addon integration)5