Forum Discussion

14 Replies

  • and to have it load faster This is what I use to get content



    Function InitShowFeedConnection(category As String) As Object

    conn = CreateObject("roAssociativeArray")

    conn.UrlPrefix = Url()
    conn.UrlShowFeed = conn.UrlPrefix + "/movies.php?cat="+spaceEscape(category)

    conn.Timer = CreateObject("roTimespan")

    conn.LoadShowFeed = load_show_feed
    conn.ParseShowFeed = parse_show_feed
    conn.InitFeedItem = init_show_feed_item

    print "created feed connection for " + conn.UrlShowFeed
    return conn

    End Function


    '******************************************************
    'Initialize a new feed object
    '******************************************************
    Function newShowFeed() As Object

    o = CreateObject("roArray", 100, true)
    return o

    End Function


    '***********************************************************
    ' Initialize a ShowFeedItem. This sets the default values
    ' for everything. The data in the actual feed is sometimes
    ' sparse, so these will be the default values unless they
    ' are overridden while parsing the actual game data
    '***********************************************************
    Function init_show_feed_item() As Object
    o = CreateObject("roAssociativeArray")

    o.ContentId = ""
    o.Title = ""
    o.ContentType = ""
    o.ContentQuality = ""
    o.Synopsis = ""
    o.Genre = ""
    o.Runtime = ""
    o.Rating = ""
    o.StreamQualities = CreateObject("roArray", 5, true)
    o.StreamBitrates = CreateObject("roArray", 5, true)
    o.StreamUrls = CreateObject("roArray", 5, true)

    return o
    End Function


    '*************************************************************
    '** Grab and load a show detail feed. The url we are fetching
    '** is specified as part of the category provided during
    '** initialization. This feed provides a list of all shows
    '** with details for the given category feed.
    '*********************************************************
    Function load_show_feed(conn As Object) As Dynamic

    if validateParam(conn, "roAssociativeArray", "load_show_feed") = false return invalid

    print "url: " + conn.UrlShowFeed
    http = NewHttp(conn.UrlShowFeed)

    m.Timer.Mark()
    rsp = http.GetToStringWithRetry()
    print "Request Time: " + itostr(m.Timer.TotalMilliseconds())

    response = ParseJson(rsp)

    feed = newShowFeed()
    m.Timer.Mark()
    m.ParseShowFeed(response.posts, feed)
    print "Show Feed Parse Took : " + itostr(m.Timer.TotalMilliseconds())

    return feed

    End Function


    '**************************************************************************
    '**************************************************************************
    Function parse_show_feed(posts As Object, feed As Object) As Void

    showCount = 0

    for each curShow in posts

    item = init_show_feed_item()

    'fetch all values from the xml for the current show
    item.ContentId = curShow.ContentId
    item.ContentType = "episode"
    item.Title = curShow.Title
    item.Description = curShow.Description
    item.Length = curShow.Length
    item.Rating = curShow.Rating
    item.StarRating = curShow.StarRating
    item.Categories = curShow.Categories
    item.Director = curShow.Director
    item.Actors = curShow.Actors
    item.ReleaseDate = curShow.ReleaseDate
    item.StreamFormat = curShow.StreamFormat
    item.StreamBitrates = curShow.StreamBitrates
    item.StreamUrl = curShow.StreamUrl
    item.SubtitleUrl = curShow.SubtitleUrl

    item.StreamQualities = curShow.StreamQualities

    item.HDPosterUrl = curShow.HDPosterUrl
    item.SDPosterUrl = curShow.SDPosterUrl

    'Set Default screen values for items not in feed
    item.HDBranded = curShow.SubtitleUrl
    item.IsHD = curShow.SubtitleUrl
    item.fullHD = curShow.fullHD
    item.Categories = curShow.Categories
    item.Actors = curShow.Actors
    item.Director = curShow.Director

    showCount = showCount + 1
    feed.Push(item)

    skipitem:

    next

    End Function

  • "TheEndless" wrote:
    It's not entirely clear what you're asking. The GridScreen will open as soon as you call screen.show(). In your code, you're not calling screen.show() until after you've loaded the data. If you call screen.show() immediately after calling screen.setListNames(categoryList), it might do what you asking, but the speed of the show will still be dependent on how long your getCategoryListMovies() takes.



    how to make speed the getCategoryListMovies() is fast
  • "hugetv" wrote:
    "TheEndless" wrote:
    It's not entirely clear what you're asking. The GridScreen will open as soon as you call screen.show(). In your code, you're not calling screen.show() until after you've loaded the data. If you call screen.show() immediately after calling screen.setListNames(categoryList), it might do what you asking, but the speed of the show will still be dependent on how long your getCategoryListMovies() takes.

    how to make speed the getCategoryListMovies() is fast

    You'll probably need to address that on the server side. Building the list itself shouldn't be that bad on the Roku, so my guess is that it's the request to the server that's taking the longest time.
  • I have on the server side a pager but not as part of roku do I have no idea