-
Notifications
You must be signed in to change notification settings - Fork 14
spectator
Replay files can be opened via SpectatedGame.openFile()
or the constructor of RoflFile, which takes an additional timeout argument for decoding the file.
SpectatedGame fromFile = SpectatedGame.openFile("PBE1-34460609.rofl");
fromFile = new RoflFile(new File("PBE1-34460609.rofl"), 5, TimeUnit.SECONDS); // Equivalent
First, create a SpectatorApiHandler for the specified region:
SpectatorApiHandler handler = new SpectatorApiHandler(Shard.EUW);
List featured games with handler.getFeaturedGames()
. Once you have a featured game, you can start spectating it with handler.openFeaturedGame()
.
InProgressGame game = handler.openFeaturedGame(handler.getFeaturedGames().get(0));
For nonfeatured games, you need to know the platform on which they are played, the game id and the encryption key, which you can retrieve via RTMP (GameService.retrieveInProgressSpectatorGameInfo
)
InProgressGame game = handler.openGame(Platform.EUW, gameId, encryptionKey);
By default, just opening the game won't load any chunks. For this, there is the GamePool
class.
Submit InProgressGames to the pool via GamePool.submit()
. This will poll the game in the background until the game is completed. If you just want to poll a single game, the static factory method GamePool.singleton()
will create a GamePool and submit the specified game in one go.
The format for chunks and keyframes is currently unknown. Therefore, the Chunk and Keyframe objects right now are only a thin wrapper around byte[]. See leaguespec for current discussion and research.
SpectatedGame.getKeyframe(id)
and SpectatedGame.getChunk(id)
retrieve the specified chunk. For file-based games, this method will return immediately. For in-progress games, this will block until the chunk or keyframe has been polled (Remember that this means that if you don't submit the game to a GamePool and don't schedule any polling yourself, those methods will never return). Again, if you prefer async calls, InProgressGame.getFutureKeyFrame(id)
and InProgressGame.getFutureChunk(id)
return futures.
If you want to see if a chunk or keyframe has been already loaded, InProgressGame.isChunkLoaded(id)
(and the keyframe equivalent) return true if the respective chunk has been loaded. If true, getChunk(id) is guaranteed to return immediately.