Skip to content

Commit

Permalink
Add ecp api definition
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Aug 21, 2023
1 parent baf4364 commit 4562d42
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 4 deletions.
80 changes: 79 additions & 1 deletion docs/playlet-web-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions playlet-lib/src/components/EcpArgs.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 7 additions & 3 deletions playlet-lib/src/components/MainScene.bs
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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

0 comments on commit 4562d42

Please sign in to comment.