strange error when player is suddenly exited

I am using the modified Vast video player and everything works fine until a user clicks play in a video then suddenly exits the video. (while the video is buffering) I receive the error below. No error is shown if the user exits the video gracefully. Thanks in advance.

‘Dot’ Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in …:/source/VAST_VideoScreen.brs(80)

080: RegWrite(episode.id, nowpos.toStr())
Backtrace:
Function showvideoscreen(episode As ) As Integer
file/line: /tmp/plugin/ADAAAAcaU9ft/…:/source/VAST_VideoScreen.brs(80)
Function showspringboardscreen(episode As ) As
file/line: /tmp/plugin/ADAAAAcaU9ft/pkg:/source/appScreens.brs(57)
Function main() As
file/line: /tmp/plugin/ADAAAAcaU9ft/pkg:/source/appMain.brs(56)

Showvideoscreen while loop


066: while true
067:         msg = wait(0, port)
068:         if type(msg) = "roVideoScreenEvent" then
069:             print "showVideoScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
070:             if msg.isScreenClosed()
071:                   print "Screen closed"
072:                 exit while
073:             else if msg.isfullresult()
074:                  RegDelete(episode.id)
075:                  
076:                  
077:                  
078:                 
079:             else if msg.isPartialResult()
080:                  RegWrite(episode.id, nowpos.toStr())
081:                 Google analytics track event here
082:                 
083:                  
084:             else if msg.isRequestFailed() then
085:                 showVideoFailureMessage()
086:                 'print "Video request failure: "; msg.GetIndex(); " " msg.GetData() 
087:             else if msg.isStatusMessage()
088:                 print "Video status: "; msg.GetIndex(); " " msg.GetData() 
089:             else if msg.isButtonPressed()
090:                 print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
091:             else if msg.isPlaybackPosition() then
092:                 nowpos = msg.GetIndex()
093:                 RegWrite(episode.id, nowpos.toStr())
094:               
095:             else if msg.isPaused() then
096:                
097:             else if msg.isResumed() then
098:                 
099:             end if
100:         else
101:             print "Unexpected message class: "; type(msg)
102:         end if
103:     end while 
104: end sub

The error would suggest that either “episode” or “nowpos” is invalid.

Thanks. So I removed the code

showVideoScreen | msg = Playback interrupted by user. | index =  0
<UNINITIALIZED>
showVideoScreen | msg =  | index =  0
Screen closed
Unknown event:  5 msg: 

I fixed it with this:

            else if msg.isPartialResult()
                 if msg.GetIndex() <> 0
                   RegWrite(episode.id, nowpos.toStr())
                   GA tracking events
                 endif