Skip to content

Commit

Permalink
Update 20210113
Browse files Browse the repository at this point in the history
  • Loading branch information
rokudevtools committed Jan 13, 2021
1 parent 3652b53 commit 8b72c78
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
' ********** Copyright 2020 Roku Corp. All Rights Reserved. **********

' !!! THE PRODUCT CODES USED IN THIS FILE ARE EXAMPLES !!!
' For the sample channel to work, you must update them to match products
' that you set up in your develper account.

sub ConfigureEntitlements(config as Object)
isActiveMonthly = false
isActiveAnnual = false
Expand All @@ -10,17 +16,14 @@ sub ConfigureEntitlements(config as Object)
expDate.FromISO8601String(purchase.expirationDate)

' check for trial purchases, even expired ones
' FIXME: please, replace this codes to created codes in the Developer Dashboard
if purchase.code = "monthly_trial_product_code" or purchase.code = "annual_trial_product_code"
isTrialUsed = true
end if

' check active (not expired) purchases
if expDate.AsSeconds() > nowDate.AsSeconds()
' FIXME: please, replace this codes to created codes in the Developer Dashboard
if purchase.code = "monthly_product_code" or purchase.code = "monthly_trial_product_code"
isActiveMonthly = true
' FIXME: please, replace this codes to created codes in the Developer Dashboard
else if purchase.code = "annual_product_code" or purchase.code = "annual_trial_product_code"
isActiveAnnual = true
end if
Expand All @@ -32,14 +35,12 @@ sub ConfigureEntitlements(config as Object)
' no active subs, check if trial has been used
if isTrialUsed
' prompt user with non-trial versions of both products
' FIXME: please, replace this codes to created codes in the Developer Dashboard
config.displayProducts = [
{name:"Monthly sub", code: "monthly_product_code"}
{name:"Annual sub", code: "annual_product_code"}
]
else
' trial wasn't used, prompt user with trial versions of both products
' FIXME: please, replace this codes to created codes in the Developer Dashboard
config.displayProducts = [
{name: "Monthly trial", code: "monthly_trial_product_code"}
{name: "Annual trial", code: "annual_trial_product_code"}
Expand All @@ -48,14 +49,12 @@ sub ConfigureEntitlements(config as Object)
else
' have some active subs
if isActiveAnnual = true
' FIXME: please, replace this codes to created codes in the Developer Dashboard
config.displayProducts = [
{name: "Monthly product (downgrade)", code: "monthly_trial_product_code", action: "downgrade"}
{name: "Monthly product (downgrade)", code: "monthly_product_code", action: "downgrade"}
]
else 'isActiveMonthly = true
' FIXME: please, replace this codes to created codes in the Developer Dashboard
config.displayProducts = [
{name: "Annual Product (upgrade)", code: "annual_trial_product_code", action: "upgrade"}
{name: "Annual Product (upgrade)", code: "annual_product_code", action: "upgrade"}
]
end if
end if
Expand Down
3 changes: 2 additions & 1 deletion samples/Roku_Recommends/components/content/CHRoot.brs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

sub GetContent()
url = CreateObject("roUrlTransfer")
url.SetUrl("http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0249f5c83/media.rss")
url.SetUrl("https://devtools.web.roku.com/samples/sample_content.rss")
url.SetCertificatesFile("common:/certs/ca-bundle.crt")
rsp = url.GetToString()

responseXML = ParseXML(rsp)
Expand Down
44 changes: 18 additions & 26 deletions samples/audio_mode/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# SGDEX Guide: Media
# SGDEX Guide: Audio Using MediaView

## Part 1: Creating the media view
## Part 1: Creating the MediaView

Create the file "MediaPlayerLogic.brs" in the components folder and implement function CreateMediaPlayer() for displaying the MediaView. Like with the other views, we need to create the object, set all needed fields and observers and then return created view. Your function should look like the one below

```
function CreateMediaPlayer() as Object
audio = CreateObject("roSGNode", "MediaView")
content = CreateObject("roSGNode", "ContentNode")
content.Update({
HandlerConfigMedia: {
name: "CHAudio"
}
},true)
audio.ObserveFieldScoped("state", "OnStateChanged")
audio.isContentList = true
audio.preloadContent = true
Expand All @@ -39,19 +32,22 @@ function CreateMediaPlayerItem(content as Object, index as Integer, isContentLis
end function
```

Content structure should be the same as for MediaView each piece of content will look something like this:
Content structure should be the same as for video content each piece of content will look something like this:

```
<Component: roSGNode:ContentNode> =
{
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id: ""
handlerconfigmedia: invalid
STREAMFORMAT: "mp3"
TITLE: "Audio 1"
URL: "http://devtools.web.roku.com/samples/audio/John_Bartmann_-_05_-_Home_At_Last.mp3"
title: "Item 1.1"
hdPosterUrl: "http://devtools.web.roku.com/samples/audio/nps_poster.jpg"
description: "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of de Finibus Bonorum et Malorum"" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, ""Lorem ipsum dolor sit amet.."", comes from a line in section 1.10.32."
releaseDate: "25.12.2018"
rating: "7.5"
artists: "Barack Gates, Bill Obama" ' artist metadata will be displayed on MediaView
album: "Achtung"
StationTitle: "Station Title" ' this field can be used to display an album title on MediaView
url: "http://www.sdktestinglab.com/Tutorial/sounds/audionode.mp3"
streamFormat : "mp3" ' if the mode field is not set on MediaView, streamFormat will be used to choose the mode
length: 3 ' this field should be set to see progress bar on MediaView
}
```
Expand All @@ -66,13 +62,13 @@ Now we go back to the DetailsViewLogic.brs file.  In the ShowDetailsView() func
m.details.ObserveField("buttonSelected", "OnButtonSelected")
```

# This paragraph says that you need to check if button id is play but the code is not doing that, fix in readme and in test channel
In your OnButtonSelected function, you need to get the details object, from that get the selected button and choose which action to perform. If the button’s id is "play" we show the MediaView using ComponentController.

```
sub OnButtonSelected(event as Object)
details = event.GetRoSGNode()
if m.audio <> invalid
buttons = event.getRoSGNode().buttons
buttonId = event.getData()
if m.audio <> invalid and buttons.getChild(buttonId).id = "play"
m.audio.control = "play"
' Show the Audio view
m.top.ComponentController.callFunc("show", {
Expand All @@ -82,8 +78,4 @@ sub OnButtonSelected(event as Object)
end sub
```

## Part 3: Using ContentHandler

Content handlers work absolutely the same as for MediaView.

###### Copyright (c) 2019 Roku, Inc. All rights reserved.
###### Copyright (c) 2020 Roku, Inc. All rights reserved.
3 changes: 2 additions & 1 deletion samples/video_preloading/components/content/CHRoot.brs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

sub GetContent()
url = CreateObject("roUrlTransfer")
url.SetUrl("http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0249f5c83/media.rss")
url.SetUrl("https://devtools.web.roku.com/samples/sample_content.rss")
url.SetCertificatesFile("common:/certs/ca-bundle.crt")
rsp = url.GetToString()

responseXML = ParseXML(rsp)
Expand Down

0 comments on commit 8b72c78

Please sign in to comment.