Kodi Development  20.0
for Binary and Script based Add-Ons

Detailed Description

Kodi's player.

Class: xbmc.Player()

To become and create the class to play something.


Example:

...
xbmc.Player().play(url, listitem, windowed)
...

Modules

 Callback functions from Kodi to Add-On
 Callback functions.
 

Function Documentation

◆ play()

play (   ...)

Function: play([item, listitem, windowed, startpos])


Play an item.

Parameters
item[opt] string - filename, url or playlist
listitem[opt] listitem - used with setInfo() to set different infolabels.
windowed[opt] bool - true=play video windowed, false=play users preference.(default)
startpos[opt] int - starting position when playing a playlist. Default = -1
Note
If item is not given then the Player will try to play the current item in the current playlist.

You can use the above as keywords for arguments and skip certain optional arguments.
Once you use a keyword, all following arguments require the keyword.

Example:

...
listitem = xbmcgui.ListItem('Ironman')
listitem.setInfo('video', {'Title': 'Ironman', 'Genre': 'Science Fiction'})
xbmc.Player().play(url, listitem, windowed)
xbmc.Player().play(playlist, listitem, windowed, startpos)
...

◆ stop()

stop ( )

Function: stop()


Stop playing.

◆ pause()

pause ( )

Function: pause()


Pause or resume playing if already paused.

◆ playnext()

playnext ( )

Function: playnext()


Play next item in playlist.

◆ playprevious()

playprevious ( )

Function: playprevious()


Play previous item in playlist.

◆ playselected()

playselected (   ...)

Function: playselected(selected)


Play a certain item from the current playlist.

Parameters
selectedInteger - Item to select

◆ isPlaying()

isPlaying ( )

Function: isPlaying()


Check Kodi is playing something.

Returns
True if Kodi is playing a file.

◆ isPlayingAudio()

isPlayingAudio ( )

Function: isPlayingAudio()


Check for playing audio.

Returns
True if Kodi is playing an audio file.

◆ isPlayingVideo()

isPlayingVideo ( )

Function: isPlayingVideo()


Check for playing video.

Returns
True if Kodi is playing a video.

◆ isPlayingRDS()

isPlayingRDS ( )

Function: isPlayingRDS()


Check for playing radio data system (RDS).

Returns
True if kodi is playing a radio data system (RDS).

◆ isExternalPlayer()

isExternalPlayer ( )

Function: isExternalPlayer()


Check for external player.

Returns
True if kodi is playing using an external player.

v18 Python API changes:
New function added.

◆ getPlayingFile()

getPlayingFile ( )

Function: getPlayingFile()


Returns the current playing file as a string.

Note
For LiveTV, returns a pvr:// url which is not translatable to an OS specific file or external url.
Returns
Playing filename
Exceptions
ExceptionIf player is not playing a file.

◆ getPlayingItem()

getPlayingItem ( )

Function: getPlayingItem()


Returns the current playing item.

Returns
Playing item
Exceptions
ExceptionIf player is not playing a file.

v20 Python API changes:
New function added.

◆ getTime()

getTime ( )

Function: getTime()


Get playing time.

Returns the current time of the current playing media as fractional seconds.

Returns
Current time as fractional seconds
Exceptions
ExceptionIf player is not playing a file.

◆ seekTime()

seekTime (   ...)

Function: seekTime(seekTime)


Seek time.

Seeks the specified amount of time as fractional seconds. The time specified is relative to the beginning of the currently. playing media file.

Parameters
seekTimeTime to seek as fractional seconds
Exceptions
ExceptionIf player is not playing a file.

◆ setSubtitles()

setSubtitles (   ...)

Function: setSubtitles(subtitleFile)


Set subtitle file and enable subtitles.

Parameters
subtitleFileFile to use as source ofsubtitles

◆ showSubtitles()

showSubtitles (   ...)

Function: showSubtitles(visible)


Enable / disable subtitles.

Parameters
visible[boolean] True for visible subtitles.

Example:

...
xbmc.Player().showSubtitles(True)
...

◆ getSubtitles()

getSubtitles ( )

Function: getSubtitles()


Get subtitle stream name.

Returns
Stream name

◆ getAvailableSubtitleStreams()

getAvailableSubtitleStreams ( )

Function: getAvailableSubtitleStreams()


Get Subtitle stream names.

Returns
List of subtitle streams as name

◆ setSubtitleStream()

setSubtitleStream (   ...)

Function: setSubtitleStream(stream)


Set Subtitle Stream.

Parameters
iStream[int] Subtitle stream to select for play

Example:

...
xbmc.Player().setSubtitleStream(1)
...

◆ updateInfoTag()

updateInfoTag ( )

Function: updateInfoTag(item)


Update info labels for currently playing item.

Parameters
itemListItem with new info
Exceptions
ExceptionIf player is not playing a file
v18 Python API changes:
New function added.

Example:

...
item = xbmcgui.ListItem()
item.setPath(xbmc.Player().getPlayingFile())
item.setInfo('music', {'title' : 'foo', 'artist' : 'bar'})
xbmc.Player().updateInfoTag(item)
...

◆ getVideoInfoTag()

getVideoInfoTag ( )

Function: getVideoInfoTag()


To get video info tag.

Returns the VideoInfoTag of the current playing Movie.

Returns
Video info tag
Exceptions
ExceptionIf player is not playing a file or current file is not a movie file.

◆ getMusicInfoTag()

getMusicInfoTag ( )

Function: getMusicInfoTag()


To get music info tag.

Returns the MusicInfoTag of the current playing 'Song'.

Returns
Music info tag
Exceptions
ExceptionIf player is not playing a file or current file is not a music file.

◆ getRadioRDSInfoTag()

getRadioRDSInfoTag ( )

Function: getRadioRDSInfoTag()


To get Radio RDS info tag

Returns the RadioRDSInfoTag of the current playing 'Radio Song if. present'.

Returns
Radio RDS info tag
Exceptions
ExceptionIf player is not playing a file or current file is not a rds file.

◆ getTotalTime()

getTotalTime ( )

Function: getTotalTime()


To get total playing time.

Returns the total time of the current playing media in seconds. This is only accurate to the full second.

Returns
Total time of the current playing media
Exceptions
ExceptionIf player is not playing a file.

◆ getAvailableAudioStreams()

getAvailableAudioStreams ( )

Function: getAvailableAudioStreams()


Get Audio stream names

Returns
List of audio streams as name

◆ setAudioStream()

setAudioStream (   ...)

Function: setAudioStream(stream)


Set Audio Stream.

Parameters
iStream[int] Audio stream to select for play

Example:

...
xbmc.Player().setAudioStream(1)
...

◆ getAvailableVideoStreams()

getAvailableVideoStreams ( )

Function: getAvailableVideoStreams()


Get Video stream names

Returns
List of video streams as name

◆ setVideoStream()

setVideoStream (   ...)

Function: setVideoStream(stream)


Set Video Stream.

Parameters
iStream[int] Video stream to select for play

Example:

...
xbmc.Player().setVideoStream(1)
...