From 4562d42ede597f584951808be609cc3ee173c51f Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 21 Aug 2023 19:46:38 -0400 Subject: [PATCH] Add ecp api definition --- docs/playlet-web-api.yml | 80 ++++++++++++++++++++++++- playlet-lib/src/components/EcpArgs.bs | 12 ++++ playlet-lib/src/components/MainScene.bs | 10 +++- 3 files changed, 98 insertions(+), 4 deletions(-) diff --git a/docs/playlet-web-api.yml b/docs/playlet-web-api.yml index 9aab044a..564ee44f 100644 --- a/docs/playlet-web-api.yml +++ b/docs/playlet-web-api.yml @@ -14,7 +14,7 @@ info: servers: - url: http://{ROKU_DEV_TARGET}:{PORT} - description: Playlet server server + description: Playlet server variables: ROKU_DEV_TARGET: description: The IP address of the Roku device @@ -158,6 +158,84 @@ paths: "204": description: No Content + # Roku External Control Protocol (ECP) + /input/{appId}: + servers: + - url: http://{ROKU_DEV_TARGET}:8060 + description: Roku ECP endpoint + variables: + ROKU_DEV_TARGET: + description: The IP address of the Roku device + default: 192.168.1.x + post: + summary: Play video using ECP input + description: Play a video using the ECP input API. This enables the deep-linking functionality. + operationId: ecpInputPlayVideo + parameters: + - name: appId + in: path + description: The app ID of the Playlet app + required: true + schema: + type: string + enum: + - "693751" # Playlet app id + - dev + default: "693751" + - name: contentId + in: query + description: The video ID of the video to play + required: true + schema: + type: string + - name: timestamp + in: query + description: The timestamp of the video to play + required: false + schema: + type: string + responses: + "200": + description: OK + /launch/{appId}: + servers: + - url: http://{ROKU_DEV_TARGET}:8060 + description: Roku ECP endpoint + variables: + ROKU_DEV_TARGET: + description: The IP address of the Roku device + default: 192.168.1.x + post: + summary: Play video using ECP launch arguments + description: Play a video using the ECP launch API. This enables the deep-linking functionality. + operationId: ecpLaunchPlayVideo + parameters: + - name: appId + in: path + description: The app ID of the Playlet app + required: true + schema: + type: string + enum: + - "693751" # Playlet app id + - dev + default: "693751" + - name: contentId + in: query + description: The video ID of the video to play + required: true + schema: + type: string + - name: timestamp + in: query + description: The timestamp of the video to play + required: false + schema: + type: string + responses: + "200": + description: OK + components: schemas: ExecuteRpcRequest: diff --git a/playlet-lib/src/components/EcpArgs.bs b/playlet-lib/src/components/EcpArgs.bs index 72927c7e..f2b8f25b 100644 --- a/playlet-lib/src/components/EcpArgs.bs +++ b/playlet-lib/src/components/EcpArgs.bs @@ -33,5 +33,17 @@ function ProcessArguments(args as object) as void rpcArgs = ParseJson(args.args) end if m.webServer.callFunc(args.func, rpcArgs) + return + end if + + if not StringUtils.IsNullOrEmpty(args.contentId) + playVideoArgs = { + videoId: args.contentId + } + if args.timestamp <> invalid + playVideoArgs.timestamp = args.timestamp.ToInt() + end if + m.webServer@.PlayVideo(playVideoArgs) + return end if end function diff --git a/playlet-lib/src/components/MainScene.bs b/playlet-lib/src/components/MainScene.bs index 96c7cef8..4d00dc70 100644 --- a/playlet-lib/src/components/MainScene.bs +++ b/playlet-lib/src/components/MainScene.bs @@ -1,13 +1,12 @@ import "pkg:/components/parts/AutoBind/AutoBind.part.bs" import "pkg:/source/utils/LoadingScreen.bs" import "pkg:/source/utils/Logging.bs" -import "EcpArgs.bs" +import "pkg:/components/EcpArgs.bs" function Init() InitializeLogging() m.log = new log.Logger("MainScene") m.scene = m.top.getScene() - m.webServer = m.top.findNode("WebServer") ' At this point, the "MainScene" node is not yet added to the scene, and does not have a parent yet. ' Let's wait until it has one. m.MainSceneContainer = m.scene.findNode("MainSceneContainer") @@ -16,7 +15,12 @@ end function function MainSceneContainerChanged() AutoBindSceneGraph() + StartWebServer() + HideLoadingScreen() InitEcpArgs() +end function + +function StartWebServer() + m.webServer = m.top.findNode("WebServer") m.webServer@.StartServer(invalid) - HideLoadingScreen() end function