Commit Graph

21 Commits

Author SHA1 Message Date
Synced Synapse 7dfd982643 Tweak connection threads
This PR fixes some issues with connections and threading. Specifically, the  change in #618 introduced threading in `HostConnection`, which had some issues. To fix them, the following changes were made:
- A specific TCP listener thread is used and manually started, instead of using one of the threads in the pool. The TCP listener thread is a long lived thread that should always be running (as long as the connection is through TCP), blocked listening on the TCP socket, so it shouldn't be managed in a pool, where, theoretically, it can be paused and reused. 
- Changed the number of threads to 5. We shouldn't need more than this, otherwise we can overwhelm some Kodi hardware.
- Had to sprinkle some `synchronized` to avoid race conditions. For instance, through a TCP connection, as soon as Kore is opened (on the remote screen) it will call at least `GetActivePlayers`, `GetProperties`, `Ping`. If the TCP socket isn't set up yet, each of these calls would create a socket (and a TCP listener thread), so we would open 3 or more sockets when we should just open 1. A `synchronized` in `executeThroughTcp` prevents this. The others prevent similar issues.

Aditionally:
- Tweaked the playlist fetching code, so that it happens exclusively in `HostConnectionObserver` and when PlaylistFragment is notified of changes, it already gets the playlist data. This somewhat simplifies the code, and makes it more consistent with the Player Observer code;
- Change `EventServerConnection` to accept a Handler on which to post the result of the connection, so that the caller can control on which thread the result is called;
- Calls to the various `RegisterObserver` loose the reply immediately parameter, as it was always true.
2019-09-28 22:10:04 +02:00
Martijn Brekhof cdbdd98d6a Implemented showing playlists even when not playing (#618)
Implemented showing a music/video/picture playlist in PlaylistFragment even
when playback has stopped but the playlist is still available on Kodi.
The playlist is now only cleared if the Playlist.OnClear event is received
from Kodi.

As the pictures playlist does not support moving/removing items this has
been disabled for the pictures playlist only.

Added a new package org.xbmc.kore.host.actions to hold all Callable's that
we use to handle complex interactions with Kodi that use multiple JSON RPC
calls.

Fixed issue in HostConnectionObserver in method notifySomethingIsPlaying
where hostState.lastGetItemResult.label might not be set.

Reduced calling (force)refreshPlaylist considerably as it should now be
handled by the playlist observer.
2019-03-30 11:08:58 +00:00
Synced Synapse c043c04264 Add support for OnAVStart event and tweak HostConnectionOberver 2019-02-08 22:30:48 +01:00
Erik Rudisch 2693d62702 Add addons search 2018-12-27 16:21:07 +00:00
Synced Synapse de683826ad Add support for handling Player.OnResume event through TCP
As detailed in https://github.com/xbmc/xbmc/pull/13726#issuecomment-378188082, Kodi will stop using the event Player.OnPlay when resuming a video, sending a Player.OnResume event instead. This PR handles that change.
2018-05-04 21:10:06 +02:00
Synced Synapse 75f8326fe4 Simplify sharing intent handling
Redesign ApiFuture to be more generic and independent of other classes
2018-04-24 13:36:35 +02:00
Synced Synapse 246693a7cc Change the source of AlbumGenres table to support Kodi v18
As detailed in https://github.com/xbmc/xbmc/pull/13051, Kodi v18 changes the way album genres are handled, as the genre (by which i mean `genreId`) ceases to be available at the album level, being only available at the songs level.
This impacts Kore because `GetAlbums` and `GetAlbumDetails` won't return the `genreId` tag, from which the local AlbumGenres table was populated.

This PR changes the source of the local AlbumGenres table to be the `genreId` returned at the song level (by `GetSongs`), to make it somewhat more consistent with the way Kodi will handle things from now on.
2018-02-22 20:57:37 +01:00
Martijn Brekhof e2c39e35ba Redesigned playing movies on device running Kore
* Implemented a new widget "fabspeeddial"
   * Provides user with two options to play the media item. One
     option to play the item on Kodi, one to play it on the remote.
   * Replaced deprecated FAB button from
     com.melnykov:floatingactionbutton:1.3.0 with the FAB button from
     the design library
   * Implemented a busy indicator (pulsate) when fab button is clicked
     and JSON  API method is still pending
   * Added a setting to allow the user to disable local playback and
     revert back to the old behaviour
* Refactored AbstractFragmentInfo
   * Replaced RelativeLayout by CoordinatorLayout to support
     hiding/showing the FAB button when scrolling
   * Replaced the tree view observer to fade out art view when scrolling
     with a behavior for the CoordinaterLayout
* Removed empty theme file for v19
* Refactored HostConnection to allow new activities to attach its
  callbacks to any pending ApiMethod. This is required to support device
  configuration changes.
2018-02-09 11:23:52 +00:00
Mon Zafra 1e9160c733 Refactored share logic to show a notification when an item is added to the playlist (#473)
- added method to HostConnection that returns a Future object instead of
  taking a callback.
- added logic for handling null Handlers in HostConnection methods
- added method to HostManager to run a function that takes a HostConnection
  in a background thread where the Future API results above can be
  synchronously composed.
- replaced chain of callbacks in RemoteActivity with a sequence of
  future gets in OpenSharedUrl.
2018-01-26 14:03:30 +00:00
Martijn Brekhof cb430aa20d Implemented a slideup panel with media controls and info (#320)
* The slideup panel is only displayed when something is
         playing. It starts collapsed showing the media poster
         and title of what is currently playing.

       * Media controls implemented are volume, progress, shuffle,
         repeat and play/pause for all items. Next and previous are only
         available when a music item is playing.

       * In collapsed mode the panel will display the mute button only
         if Kodi is muted. The mute button in expanded mode is always
         visible.

       * Panel is enabled by default. Users can disable the panel
         in Settings

       * Implemented listening to Player.OnPropertyChanged notifications
         to update shuffle and repeat button states.
2017-07-13 19:10:49 +01:00
Aneesh Agrawal 66c145d778 Enable manual configuration of https (#338)
* Allow specifying HTTPS Hosts manually
This is not exposed in the UI, but on the manual host configuration screen, if the address starts with a  "http://" or "https://" this will be stripped and the `isHttps` flag set appropriately.

Additionally, the port can be configured as part of the address as well.
Any port specified as part of the address takes precedence over the explicit HTTP port box, to allow easy copy-pasting of an entire URL for a host.

This enables using Kore with Kodi instances available though HTTPS (e.g. via a reverse proxy).
2017-01-27 15:17:39 +00:00
Martijn Brekhof d993126c7e Fixed retrieving wrong handler for applicationNotificationsObserver (#319) 2016-12-02 11:04:17 +00:00
Martijn Brekhof c5848ce648 Implemented showing volume level on NowPlayingFragment (#312)
Replaced up/down volume buttons with a seekbar that displays the current
volume level and can be used to change the volume level
2016-11-30 12:20:21 +00:00
aharonha 39afba2ae3 Fix default charset in okHttp
should fix RTL languages such as Arabic, Hebrew and Thai
2015-10-25 01:08:39 +02:00
Synced Synapse 17e9ad5aaf Catch an exception that is being reported in Google Play, when user enters a malformed URL as the media center address. This causes a RuntimeException on OkHttp which wasn't being handled. Ideally we should validate the hostname/ip address that the user enters, but i'm not sure that Patterns.IP_ADDRESS/Patterns.DOMAIN_NAME/Patterns.WEB_URL catches all the possible cases, so i opted for the lazy solution, catch the exception 2015-05-25 23:17:41 +01:00
Synced Synapse 5aa674daf4 Disable http keep-alive if we get a ProtocolException (bad status line) from the server. 2015-04-21 09:57:41 +01:00
Synced Synapse f732e0b822 Fix some log messages 2015-04-19 12:13:50 +01:00
Synced Synapse 1fc9eb3301 Switched HTTP library. Using OkHttp explicitly now, instead of the default Android one, which varies acroos OS versions.
OkHttp is also used as the backend for loading images (Picasso).
Added disk cache to image loading.
2015-04-18 10:52:31 +01:00
DanhDroid dfcb6d7d4d fix up typo on ApiCallback.onSucess() 2015-03-16 11:33:40 -07:00
Synced Synapse 551583aa9d Fix some build warnings. 2015-03-09 22:05:58 +00:00
Synced Synapse ed584fb9b7 Changed namespace/appid to org.xbmc.kore 2015-03-09 21:35:18 +00:00