playall videos like onion news network

Endless how did you get this to work?

I just added this channel and i really like how that works.

Can you share with us how you got this play all in the category list? this would be great for youtube btw!! wonder if chris could do something similar as well would make that experience smoother.

Chris prefers having the “Play All” button on the springboard. That way the user can begin the play all experience from any video in the list.

Chris you know i saw that play all and i thought i tried using it once and it didnt work, but i just went back and tried it and I love it!! thanks Chris it works awesome

So can you guys let us in on how you did this? and some code snipplet would be awesome.

I think i might like to add this, in the trailers sections as they are always short clips

I use essentially the logic discussed in this thread viewtopic.php?f=34&t=32867

Chris,
i got this “somehwhat” working…

here is my code, using the videoplayer example appVideoScreen.brs

Function showVideoScreen(episode As Object)

    if type(episode) <> "roAssociativeArray" then
        print "invalid data passed to showVideoScreen"
        return -1
    endif

url = "http://xxx.com/get/IptvMyWay-670.m4v"
fmt = "mp4"

url2 = episode.StreamUrls 
fmt2 = episode.StreamFormat

print " this is the url:  ";url2
print " this is the Format:  ";fmt2

videoArray = [
        {
        Stream: { url: url }
        StreamFormat: fmt
        },
        {
        Stream: { url: url }
        StreamFormat: fmt
        }
        ]

for each video in videoArray

  screen = CreateObject("roVideoScreen")
  screen.SetMessagePort(CreateObject("roMessagePort"))
  screen.SetPositionNotificationPeriod(30)
  screen.SetContent(video)
  screen.Show()

    'Uncomment his line to dump the contents of the episode to be played
	'PrintAA(episode)

    while true
msg = wait(0, screen.GetMessagePort())

        if type(msg) = "roVideoScreenEvent" then
            print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
            if msg.isScreenClosed()
                print "Screen closed"
                exit while
            elseif msg.isRequestFailed()
                print "Video request failure: "; msg.GetIndex(); " " msg.GetData() 
            elseif msg.isStatusMessage()
                print "Video status: "; msg.GetIndex(); " " msg.GetData() 
            elseif msg.isButtonPressed()
                print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
            elseif msg.isPlaybackPosition() then
                nowpos = msg.GetIndex()
                RegWrite(episode.ContentId, nowpos.toStr())
            else
                print "Unexpected event type: "; msg.GetType()
            end if
        else
            print "Unexpected message class: "; type(msg)
        end if
    end while
next
End Function

ok this code above works. BUT not the correct way.

the url2 and fmt2 when printed show the correct format and url… but they will not play just goes back to the springboard screen…

the error i get is:


 this is the url:  http://xxxx.com/get/IptvMyWay-95.m4v
 this is the Format:  mp4

showHomeScreen | msg = An unexpected problem (but not server timeout or HTTP err
or) has been detected. | index = -3
Video request failure: -3  0
showHomeScreen | msg =  | index =  0
Screen closed

what i don’t understand is it does print out as the correct URL and Format, but it just poops out this error.

Well, the first thing I notice is that you aren’t trying to play url2. You print it to the console, but it’s not part of your videoArray.

Also keep in mind that anytime a screen closes, control falls back to the previous open screen. So if you don’t open a canvas or some other blank screen beneath your series of video screens, you will lose control after the first video and fall back to the springboard. That was discussed in this thread: viewtopic.php?f=34&t=32501&p=206093&hilit=simulating#p204249

“RokuChris” wrote:
Well, the first thing I notice is that you aren’t trying to play url2. You print it to the console, but it’s not part of your videoArray.

Also keep in mind that anytime a screen closes, control falls back to the previous open screen. So if you don’t open a canvas or some other blank screen beneath your series of video screens, you will lose control after the first video and fall back to the springboard. That was discussed in this thread: viewtopic.php?f=34&t=32501&p=206093&hilit=simulating#p204249

as i stated i did have it in that way but it just closes, if i keep it the way it is it plays them both just fine… the full example i had works just fine.

It is when i try addding into the array and changing it to this

videoArray = [
        {
        Stream: { url: url }
        StreamFormat: fmt
        },
        {
        Stream: { url: url2 }
        StreamFormat: fmt2
        }
        ]

it plays the first video but not the second video, and when i print it. It does show that the format and url are correct.

If the code works fine and only breaks when you change a URL, the problem could be with that content. Do you know whether that video plays on Roku at all?

Also, you’re setting url2 = episode.streamURLs, which is most likely an array, but url2 needs to be a string for things to work right. If you’re feeding the video screen an array where it expects a string, that could be the issue.

I’d bet this line is your problem: “url2 = episode.StreamUrls”

Why are you using StreamUrls here, but using the Stream associative array in your content array? StreamUrls is an array of strings, whereas Stream.Url is a single string. I don’t know what “episode” looks like, but I would think that line should either be “url2 = episode.StreamUrls[0]” or “url2 = episode.Stream.Url”.

“RokuChris” wrote:
If the code works fine and only breaks when you change a URL, the problem could be with that content. Do you know whether that video plays on Roku at all?

yes for testing i am using the same videos from my fishing channel, its somehow in the code. because as soon as i change it back to normal it plays just fine

i was thinking it had something to do with the episode and video variables?

the video player uses

screen.content(episode)   

but i changed that to

screen.content(video) 

“TheEndless” wrote:
I’d bet this line is your problem: “url2 = episode.StreamUrls”

Why are you using StreamUrls here, but using the Stream associative array in your content array? StreamUrls is an array of strings, whereas Stream.Url is a single string. I don’t know what “episode” looks like, but I would think that line should either be “url2 = episode.StreamUrls[0]” or “url2 = episode.Stream.Url”.

i used url2 = episode.StreamUrls[0] and that worked, but i need to play with it a bit because its not playing it as a 2 minute preview as i had it set up. so must be something else in there i am missing

also is there a way to stop the FF in these? i thought i read that somewhere, i know how to disable the Nav i have done that

hey endless how about some help on how to create that array correctly in my other example, i lost half a head of hair on that already!

Why are you copying the data from “episode” into new objects? It sounds like they’re already valid content items, so why not just pass them directly in the array to the video player instead?

videoArray = [
  ' Pre-roll
  {
    Stream: { url: url }
    StreamFormat: fmt
  },
  ' Episode
  episode
]

The content item you’re currently passing to the video player only has a URL and a StreamFormat… it doesn’t have a PlayDuration for a preview.

that worked endless thanks… i tried something similar to that last night and i cant remember what happened to it but it didnt work.

yeah its odd even though the duration is set at 2 minutes it will play past that, but its only showing 2 min on ther video and if you try to FF it will go back to a earlier time its strange.

how could i keep that duration in tact?

right now im adding the controls of the canvas.

“dynamitemedia” wrote:
that worked endless thanks… i tried something similar to that last night and i cant remember what happened to it but it didnt work.

yeah its odd even though the duration is set at 2 minutes it will play past that, but its only showing 2 min on ther video and if you try to FF it will go back to a earlier time its strange.

how could i keep that duration in tact?

right now im adding the controls of the canvas.
If PlayDuration doesn’t work (I’ve never used it, so I don’t know), you could capture the PositionNotification event and stop the video once it’s reached or exceeded two minutes.

the duration has worked until now, and i think its cause of in the app detail screen its not setup for the prerolls and will do duration on the first video it plays.

which the preroll is only like 20 seconds …

PlayDuration should be set on your “episode” object. You’re creating a new video screen for each video in your array, so they are independent of each other. It doesn’t have anything to do with the fact that you’re playing multiple videos. If it was working before, but isn’t now, then you probably inadvertently changed something somewhere.

actually it is working just fine, i cant seem to recreate what that issue was before…

“TheEndless” wrote:
If PlayDuration doesn’t work (I’ve never used it, so I don’t know), you could capture the PositionNotification event and stop the video once it’s reached or exceeded two minutes.

couldn’t you essentially do this to play a “midroll” ad video?

“dynamitemedia” wrote:

“TheEndless” wrote:
If PlayDuration doesn’t work (I’ve never used it, so I don’t know), you could capture the PositionNotification event and stop the video once it’s reached or exceeded two minutes.

couldn’t you essentially do this to play a “midroll” ad video?
In combination with the PlayStart attribute, yes. You’d want to make sure you break on a segment boundary, though, if using HLS, otherwise you could get some repeated video when you restart playback.

“TheEndless” wrote:
In combination with the PlayStart attribute, yes. You’d want to make sure you break on a segment boundary,

sounds interesting!!

just to be sure i understand, what do you mean exactly by “segment boundary” ?

you have an example to play with to get this working ? i know i will have to make changes to it to make it work in the video player example