Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with 'videoplayer' "Resume Playing" functionality

We have built our now public app, almost entirely from the 'videoplayer' example in the SDK.

I noticed during testing and development that sometimes I would get the single "Play" button on the springboard, and other times it would have both the "Resume Playing" and the "Play from beginning" buttons.

I have gone to great lengths to ensure that each video has it's own original ID so that the playhead index can be stored for each video. I have dug through the code and I can tell that the code to set and update this 'index' is almost complete. However, the one aspect that is missing is that once at the end of a video, the index is not reset back to '0'. So that means if you watch a video all the way to the end, when it automatically goes back to the springboard, it always has the 'Resume' button.

I thought that I had broken this aspect of the code during our modifications to the 'videoplayer' example, however, upon reloading a fresh copy of the original code shipped with the SDK, I realized that this app never had the functionality of properly resetting the index back to '0' when the clip has played all the way to the end.

Anyone seen this issue or have any suggestions? I would be happy to submit code samples, however, I did not know where to start. Please let me know if there is something that would help diagnose this issue!

Thanks - Kasey
0 Kudos
13 Replies
belltown
Level 7

Re: Help with 'videoplayer' "Resume Playing" functionality

In appVideoScreen.brs, change the following code from:


elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()


to:


elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
RegWrite(episode.contentId, "0")
elseif msg.isFullResult()
print "Playback completed"
RegWrite(episode.contentId, "0")
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
https://github.com/belltown/
0 Kudos
destruk
Level 10

Re: Help with 'videoplayer' "Resume Playing" functionality

You could have it delete the registry key when the video is finished, or what I'd do is subtract a minute or so from the end and then delete it when it reached or exceeded that point as most people I know don't watch the entire ending credits.
Don't forget to update the springboard screen afterward to reflect the current status.
0 Kudos

Re: Help with 'videoplayer' "Resume Playing" functionality

"belltown" wrote:
In appVideoScreen.brs, change the following code from:


elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()


to:


elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
RegWrite(episode.contentId, "0")
elseif msg.isFullResult()
print "Playback completed"
RegWrite(episode.contentId, "0")
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()


FANTASTIC!
Thank you so much for saving me from this headache any further.
I made the change just a few minutes after your post and it works beautifully. I have already submitted the new build for an update to the version in the channel store.

"destruk" wrote:
You could have it delete the registry key when the video is finished, or what I'd do is subtract a minute or so from the end and then delete it when it reached or exceeded that point as most people I know don't watch the entire ending credits.
Don't forget to update the springboard screen afterward to reflect the current status.


Great point. However, we currently don't have standard credits in our programs as you would see in a feature movie or broadcast tv program. Mostly our credits would be included picture-in-picture with the end of the program or the credits would only roll for less than 5 seconds. But, I think this is a great idea and will look at implementing it. I might be picking your brain a bit more on this topic if that is ok.


ModsSmiley Frustratedeems like this thread should be a sticky if this feature is 'broken' in the example code, yet when a channel is submitted for public approval they are rejected when it doesn't work. Just think anyone starting with the 'videoplayer' example should know this.

Thanks again to all
0 Kudos
destruk
Level 10

Re: Help with 'videoplayer' "Resume Playing" functionality

I wouldn't use the default bookmarking channel code anyway, for any public channel with hundreds of pieces of content.
The registry entries for the bookmarking are all individually based on the contentID and it's not limited in any way in the sample channel code.
This means your 16KB for registry storage would eventually fill up for your devid and future bookmarks would not work until you factory default the roku box, or manually removed ALL your apps from the box and reinstalled them.
It's meant as an 'example tutorial' codebase.

Ideally you would write your own bookmarking system which limited and managed the roku box registry storage area itself (has been done many times, just I haven't seen any public free to use code), or you would save the bookmarks on the server in a database for later retrieval with some kind of management system per user - also rather easy to set up.
0 Kudos
belltown
Level 7

Re: Help with 'videoplayer' "Resume Playing" functionality

As a compromise, for now, you could just change these calls:


RegWrite(episode.contentId, "0")


to:


RegDelete(episode.contentId)


This will have the same result in that after the end of the content has been reached, the "Play" button will be displayed since there is no longer a stored position for that content. The advantage of deleting the registry key, as destruk mentioned, is that it will free up space in the registry by not storing position information for content items that have been played to the end.
https://github.com/belltown/
0 Kudos
bandal
Level 7

Re: Help with 'videoplayer' "Resume Playing" functionality

I have the same issue since 4.8 and how can I test that this works? I tried and played video to the end and Resume playing still shows versus Play.

Thanks,
0 Kudos
destruk
Level 10

Re: Help with 'videoplayer' "Resume Playing" functionality

You'll need to update the previous screen when it returns to the springboard to check the correct buttons are showing.
ie - if you are deleting the bookmark in the videoscreen brs file, in the detailscreen brs file, add the refreshshowdetail line after the showvideoscreen line for buttons 1 and 2.

showVideoScreen(showList[showIndex])
refreshShowDetail(screen,showList,showIndex)
0 Kudos
bandal
Level 7

Re: Help with 'videoplayer' "Resume Playing" functionality

destruk,

That did the trick and when it plays to the end, the screen pops back to Play. Thanks.
DA
0 Kudos

Re: Help with 'videoplayer' "Resume Playing" functionality

Both of you guys are awesome!

Thanks for all of the good information. I wouldn't be able to get this channel off the ground without the help and wisdom of a GOOD forum, which it appears we have here.

We are getting ready to do an official launch as soon as we get a little more content up, and it is a plus that we could also get a few kinks worked out, like this 'resume playing' issue.

For our setup, I'm not sure if it would be practical for us to do the development for the server side bookmarks system for each user until they decide to proceed on some other individual user features like recommendations based on viewing habits and/or a user generated queue. However, I think it should be included when we do either of those projects.

Honestly, after we got a few quotes of over $20,000 for 3rd party channel development, the decision was made that I would develop a basic channel in-house that would "just play the content". That has allowed us to focus more funds on new encoding hardware, and into a much better CDN service.

I am also very glad to see that the thread could help someone else. I know that I will probably never be able to offer the level of wisdom that you two can, but I will do my best to help others with anything I can.
0 Kudos