Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tattness
Level 8

EpisodeScreen.brs category index mismatch for category list

I am creating a SDK channel following the Roku published video courses using the Roku developers templates given on Github. I've sideloaded the channel to my Roku device and reached the debugging process using Visual Studio Code program. I currently have category-based videos and series on my channel and I've noticed the channel freezing when I attempt to play one of the videos in some my categories/series and I keep getting a type mismatch error on line 21 of my EpisodeScreen.brs for  if (categoryIndex - 1) = m.categoryList.jumpToItem

sub OnListItemFocused(event as Object) ' invoked when episode is focused
    focusedItem = event.GetData() ' index of episode
    ' index of season which contains focused episode
    categoryIndex = m.itemToSection[focusedItem]
    ' change focused item in seasons list
    if (categoryIndex - 1) = m.categoryList.jumpToItem
        m.categoryList.animateToItem = categoryIndex
    else if not m.categoryList.IsInFocusChain()
        m.categoryList.jumpToItem = categoryIndex
    end if
end sub

The Debugging console generes this report:
Current Function:
016: sub OnListItemFocused(event as Object) ' invoked when episode is focused
017: focusedItem = event.GetData() ' index of episode
018: ' index of season which contains focused episode
019: categoryIndex = m.itemToSection[focusedItem]
020: ' change focused item in seasons list
021:* if (categoryIndex - 1) = m.categoryList.jumpToItem
022: m.categoryList.animateToItem = categoryIndex
023: else if not m.categoryList.IsInFocusChain()
024: m.categoryList.jumpToItem = categoryIndex
025: end if
Source Digest(s):
pkg: dev 1.0.1 aa1859c8d20764eaf71363f84ec64ab3 Tattness TV

Type Mismatch. (runtime error &h18) in pkg:/components/EpisodesScreen/EpisodeScreen.brs(21)
Backtrace:
#0 Function onlistitemfocused(event As Object) As Void
file/line: pkg:/components/EpisodesScreen/EpisodeScreen.brs(21)
Local Variables:
event roSGNodeEvent refcnt=2
global Interface:ifGlobal
m roAssociativeArray refcnt=2 count:6
focuseditem roInt refcnt=1 val:-1 (&hFFFFFFFF)
categoryindex Invalid
vscodeloopkey <uninitialized>
content <uninitialized>
Threads:
ID Location Source Code
0 pkg:/source/main.brs(22) msg = wait(0, m.port)
1* ...sodesScreen/EpisodeScreen.brs(21) if (categoryIndex - 1) = m.categoryList.jumpToItem
*selected

I am completely new to coding and know basics and am usually able to search to find answers but I seem to have not found the needed answer to solve this. Just to add that one of my series does appear and play the video. I do apologize but I do greatly appreciate the help and welcome any resources to help me or pointers. Thank you!!

 

0 Kudos
3 Replies
renojim
Level 21

Re: EpisodeScreen.brs category index mismatch for category list

Most likely something hasn't been initialized properly.  Print is your best friend when trying to figure out what's wrong.  Either add print statements to your code or just enter them from the debug console when it crashes.

print categoryIndex
print m.categoryList.jumpToItem
print m.categoryList
0 Kudos
tattness
Level 8

Re: EpisodeScreen.brs category index mismatch for category list

Hi, I did include the print function in my coding for my EpisodeScreen.brs near the lines causing concern. However now I seem to have new errors in my coding:

coding.JPG

This is what comes up in my debugging log when I attempt to select a video from one of my playlists and it crashes.

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  1*   ...sodesScreen/EpisodeScreen.brs(18)    STOP

Current Function:
016:  sub OnListItemFocused(event as Object) ' invoked when episode is focused
017:      focusedItem = event.GetData() ' index of episode
018:* STOP
019:      ' index of season which contains focused episode
020:      categoryindex = m.itemToSection[focusedItem]
021:      ' change focused item in seasons list
022:      if (categoryIndex - 1) = m.categoryList.jumpToItem
Source Digest(s): 
pkg: dev 1.0.1 f005f269b5ef0689932d9e7da47afd92 Tattness TV

STOP (runtime error &hf7) in pkg:/components/EpisodesScreen/EpisodeScreen.brs(18)
Backtrace:
#0  Function onlistitemfocused(event As Object) As Void
   file/line: pkg:/components/EpisodesScreen/EpisodeScreen.brs(20)
Local Variables:
event            roSGNodeEvent refcnt=2
global           Interface:ifGlobal
m                roAssociativeArray refcnt=2 count:6
focuseditem      roInt refcnt=1 val:-1 (&hFFFFFFFF)
categoryindex    <uninitialized>
Threads:
ID    Location                                Source Code
 0    pkg:/source/main.brs(22)                msg = wait(0, m.port)
 1*   ...sodesScreen/EpisodeScreen.brs(18)    STOP
  *selected

Any suggestions?

0 Kudos
renojim
Level 21

Re: EpisodeScreen.brs category index mismatch for category list

You need to put those prints before the line that causes the crash.  Once it crashes it stops executing any more code.  Add them right before the "if (categoryindex ..." line.

0 Kudos