Jump to content

Watched status not set using external player (AndroidTV/UPnP stream)


mpiet

Recommended Posts

Because the only way to have a good playback on Sony AndroidTV without any stutterings and audio passthrough issues i have to use the stock video player. I found a great solution using emby addon for kodi to keep my media library and to watch the media via the sony player app.

 

I am using

Kodi v17.5 / SPMC v16.7.1

Emby addon via emby repository (not embycon)

Kodi external player passing video files to the sony video player app

Emby setting "direct play" (UPnP cast)

 

I read some thread about same or similar issue but i did not find a solution. Is it or will it be possible to get the watched status using external player?

 

A second issue is, that the watched progress is not stored and continuing a movie is not possible. It is only possible, when re-starting the same movie. If a first movie is started and stopped for example in the middle, starting a second movie, stopping and starting the first movie, the first movie starts always from beginning, there is no question about continuing the movie.

Link to comment
Share on other sites

Angelblue05

There's no solution to this. Kodi simply doesn't trigger any events the add-on can hook onto to detect playback status of any kind.

Link to comment
Share on other sites

OK, but the emby server knows, that a stream was started by user x and was watched to the end. Is there no sync from server to client regarding watched status or resume watching?

Link to comment
Share on other sites

Angelblue05

Do you mind providing your Kodi log? I'm just curious to see what events Kodi triggers during playback. I honestly didn't think it was possible for external player to trigger these events (playback start and playback stopped).

Link to comment
Share on other sites

@@Angelblue05, i send you my spmc and emby server log via pm. The logsettings in spmc i left by default.

 

First i started a movie, then i wind forward the move. Then i stopped the movie. Back in playlist the status was marked as watched for a second, but then the marker was removed.

I restarted the same movie, the movie started from the state that i stopped before. Then i stopped the movie. Back in playlist the status was marked as watched for a second, but then the marker was removed.

I started an other movie, stopped it and restarted the first movie. The first movie was started from beginning and not from the stated it was stopped before.

  • Like 1
Link to comment
Share on other sites

I tried this build already, but the watched status is not synchronised. But tell me, how i should proceed. Do i have to watch the full movie? Or its enough to start a movie, skip to the end and then stop the movie? And what about the set variable in playercorefactory.xml:

<playcountminimumtime>600</playcountminimumtime>

 

Do it have any influence?

Link to comment
Share on other sites

Just for the completition what i send before via pm:

 

Maybe this is interesting for you, it is a line from the playercorefactory.xml:

<player name="Video" type="ExternalPlayer" audio="false" video="true">
                        <filename>com.sony.dtv.osat.video</filename>
                        <hidexbmc>true</hidexbmc>
                        <playcountminimumtime>600</playcountminimumtime>

I think this is the timer for kodi, so if the external player is active for the set time (600 should be 10 minutes), then kodi tries to mark the movie as watched. But even this is not working, after the playback it is marked as watched for a second and than un-marked again.

The same issue can be reproduced using an android phone (install kodi, install emby addon, set playercorefactory.xml). For external player set "com.google.android.apps.photos". This app works same as the sony video player. It can only playback local and UPnP files and have no smb support.

Link to comment
Share on other sites

  • 3 weeks later...

I'm using Kodi on Ubuntu with an external player for a long time to get digital crossovers, speaker/subwoofer management and room correction working with the use of Jack Audio Server. Emby for Kodi join the team since I centralized my media management with Emby on an Debian server.

 

And there is the same error with the watched state in Kodi. When the external player finished the playback and Kodi is come back the state is set to watched by Kodi. But a second later Emby for Kodi report some database sync and setting the state back to unwatched.

 

People using external players are only a minority, I think, but is there a chance to correct this behaviour?

 

(I looked into the Kodi JSON-Api to set the watched state from an external script after the Emby sync, but this is beyond my knowledge.)

 

Thanks

kalle

Link to comment
Share on other sites

Angelblue05

Pull requests are always welcomed. The reason it's not working correctly is because of the position tick reported by Kodi.

 

For some reason, when the show ends via external player, Kodi reports the position tick as 1.0. To theoretically fix this, I need a way to know the content is being played via external player. So far, I could not find this information in the Kodi api.

 

Normal Kodi player: currentPosition and runtime. 

 

22:48:27 T:9480  NOTICE: EMBY.player -> Played_information: {"smb://x/TV/Hell's Kitchen (US)/Season 17/Hell's Kitchen (US) - 17x09 Catch Of The Day.mkv": {'paused': False, 'refresh_id': 'ee0b5c9f20002624eb95700db84ed0d9', 'AudioStreamIndex': 1, 'SubtitleStreamIndex': '', 'currentPosition': 7.569000244140625, 'item_id': '6d9973bf12224b159d2af9a35b31c1b0', 'currentfile': "smb://x/TV/Hell's Kitchen (US)/Season 17/Hell's Kitchen (US) - 17x09 Catch Of The Day.mkv", 'runtime': 25921780000L, 'Type': 'Episode', 'playmethod': 'DirectPlay'}}

 

For external players, the add-on does 1.0/runtime which doesn't pass the requirement of being watched.

EMBY.player -> Percent complete: 0.00291993846261 Mark played at: 0.9
Link to comment
Share on other sites

Thanks for looking into this very specific problem. Unfortunately I don't have the Python skills to make a pull request.

 

Because I trying to set the watched state by an external Bash script I had read a little in the JSON-RPC API of Kodi. And maybe the method Player.GetActivePlayers is what you looking for. http://kodi.wiki/view/JSON-RPC_API/v8#Player.GetActivePlayers

 

Together with the Python method executeJSONRPC provided by Kodi it should be possible to know if internal or external player is used for playback.

 

Not tested example:

response = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1 }')

Hopefully that will help a little.

 

kalle

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

For those who are interested in a little linux/bash based workaround.

 

I'm using a little wrapper script that is executed by kodi as external player.

#!/bin/bash

/usr/bin/time -o /tmp/player-time -f %e /path/to/your/player "$1"

TIME=$(cat /tmp/player-time)
TIME=${TIME%.*}

if [ $TIME -gt 1200 ]; then
	DETAILS=$(curl -s -H 'content-type: application/json;' --data-binary\
	 '{"jsonrpc": "2.0", "method": "Files.GetFileDetails", "params": {"file": "'"$1"'", "media": "video"}, "id": "bash"}'\
	 user:password@localhost:8080/jsonrpc)
	ID=${DETAILS#*'filedetails":{"id":'}
	ID=${ID%%,*}
	TYPE=${DETAILS#*'type":"'}
	TYPE=${TYPE%%'"'*}

	case "$TYPE" in
	movie)
                (sleep 10 ; curl -s -H 'content-type: application/json;' --data-binary\
                 '{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": { "movieid": '$ID', "playcount": 1 }, "id": "bash"}'\
                 user:password@localhost:8080/jsonrpc) &
	;;
	episode)
		(sleep 10 ; curl -s -H 'content-type: application/json;' --data-binary\
		 '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": { "episodeid": '$ID', "playcount": 1 }, "id": "bash"}'\
		 user:password@localhost:8080/jsonrpc) &
	;;
	esac

fi

exit 0

You can use the script with:

/path/to/your/script /path/to/video.file

Just change your player and your username, password and port for kodi. And when the player is running for longer than 1200 seconds the video file is marked as watched in the library - with a 10 seconds delay. My script also checks the played percentage but this depends on the player you using. (For mpv you can ask me.)

Link to comment
Share on other sites

Can somebody please explain me, why the watched status is not handled on server side? There is already an option to set watch timings (probably for watching via web browser) and as i posted in #7 in a screenshot, the server knows that a video is played by kodi (in truth its started by kodi and passed to external player). In this was the resume playback would also work for all files.

Link to comment
Share on other sites

The explanation is in post #15

 

 

Pull requests are always welcomed. The reason it's not working correctly is because of the position tick reported by Kodi.

 

For some reason, when the show ends via external player, Kodi reports the position tick as 1.0. To theoretically fix this, I need a way to know the content is being played via external player. So far, I could not find this information in the Kodi api.

 

Normal Kodi player: currentPosition and runtime. 

EMBY.player -> Played_information: {"smb://x/TV/Hell's Kitchen (US)/Season 17/Hell's Kitchen (US) - 17x09 Catch Of The Day.mkv": {'paused': False, 'refresh_id': 'ee0b5c9f20002624eb95700db84ed0d9', 'AudioStreamIndex': 1, 'SubtitleStreamIndex': '', 'currentPosition': 7.569000244140625, 'item_id': '6d9973bf12224b159d2af9a35b31c1b0', 'currentfile': "smb://x/TV/Hell's Kitchen (US)/Season 17/Hell's Kitchen (US) - 17x09 Catch Of The Day.mkv", 'runtime': 25921780000L, 'Type': 'Episode', 'playmethod': 'DirectPlay'}}

For external players, the add-on does 1.0/runtime which doesn't pass the requirement of being watched.

EMBY.player -> Percent complete: 0.00291993846261 Mark played at: 0.9
Link to comment
Share on other sites

So what about a check box option in the emby settings like:

Generall Settings: Using external player for all video playback: yes/no

People that are using external player have to create a xml file and put it to kodi userfolder. By this way they could change the emby setting like in the emby app for android.

One short hint could be added to the emby wiki.

Edited by mpiet
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...