2019-03-07 03:14:52 +00:00
|
|
|
sub ShowServerSelect()
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("ConfigScene")
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
2019-03-17 17:38:21 +00:00
|
|
|
scene.findNode("prompt").text = "Connect to Server"
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
|
|
|
items = [
|
|
|
|
{"field": "server", "label": "Host", "type": "string"},
|
|
|
|
{"field": "port", "label": "Port", "type": "string"}
|
|
|
|
]
|
2019-03-20 03:23:58 +00:00
|
|
|
config.configItems = items
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
button = scene.findNode("submit")
|
|
|
|
button.observeField("buttonSelected", port)
|
|
|
|
|
|
|
|
server_hostname = config.content.getChild(0)
|
|
|
|
server_port = config.content.getChild(1)
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
|
|
|
return
|
|
|
|
else if type(msg) = "roSGNodeEvent"
|
|
|
|
node = msg.getNode()
|
|
|
|
if node = "submit"
|
|
|
|
set_setting("server", server_hostname.value)
|
|
|
|
set_setting("port", server_port.value)
|
|
|
|
return
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub ShowSignInSelect()
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("ConfigScene")
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
2019-03-07 03:14:52 +00:00
|
|
|
scene.findNode("prompt").text = "Sign In"
|
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
|
|
|
items = [
|
|
|
|
{"field": "username", "label": "Username", "type": "string"},
|
|
|
|
{"field": "password", "label": "Password", "type": "password"}
|
|
|
|
]
|
2019-03-20 03:23:58 +00:00
|
|
|
config.configItems = items
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
button = scene.findNode("submit")
|
|
|
|
button.observeField("buttonSelected", port)
|
|
|
|
|
|
|
|
config = scene.findNode("configOptions")
|
|
|
|
|
|
|
|
username = config.content.getChild(0)
|
|
|
|
password = config.content.getChild(1)
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed()
|
|
|
|
return
|
|
|
|
else if type(msg) = "roSGNodeEvent"
|
|
|
|
node = msg.getNode()
|
|
|
|
if node = "submit"
|
|
|
|
' Validate credentials
|
|
|
|
get_token(username.value, password.value)
|
|
|
|
if get_setting("active_user") <> invalid then return
|
|
|
|
print "Login attempt failed..."
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub ShowLibrarySelect()
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("Library")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
2019-03-07 03:14:52 +00:00
|
|
|
library = scene.findNode("LibrarySelect")
|
|
|
|
libs = LibraryList()
|
|
|
|
library.libList = libs
|
|
|
|
|
|
|
|
library.observeField("itemSelected", port)
|
|
|
|
|
2019-03-14 21:50:42 +00:00
|
|
|
search = scene.findNode("search")
|
|
|
|
search.observeField("escape", port)
|
2019-03-14 22:20:16 +00:00
|
|
|
search.observeField("search_value", port)
|
2019-03-14 21:50:42 +00:00
|
|
|
|
2019-03-19 04:17:50 +00:00
|
|
|
sidepanel = scene.findNode("options")
|
|
|
|
new_options = []
|
|
|
|
options_buttons = [
|
2019-03-19 14:11:46 +00:00
|
|
|
{"title": "Change server", "id": "change_server"},
|
2019-03-19 04:17:50 +00:00
|
|
|
{"title": "Sign out", "id": "sign_out"}
|
|
|
|
]
|
|
|
|
for each opt in options_buttons
|
|
|
|
o = CreateObject("roSGNode", "OptionsButton")
|
|
|
|
o.title = opt.title
|
|
|
|
o.id = opt.id
|
|
|
|
new_options.append([o])
|
|
|
|
o.observeField("escape", port)
|
|
|
|
end for
|
|
|
|
|
|
|
|
sidepanel.options = new_options
|
|
|
|
sidepanel.observeField("escape", port)
|
|
|
|
|
2019-03-07 03:14:52 +00:00
|
|
|
while(true)
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
2019-03-19 00:33:44 +00:00
|
|
|
return
|
2019-03-14 21:50:42 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "search"
|
|
|
|
library.setFocus(true)
|
2019-03-19 18:19:08 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
|
|
|
|
library.setFocus(true)
|
2019-03-19 14:11:46 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "change_server"
|
|
|
|
unset_setting("server")
|
|
|
|
unset_setting("port")
|
|
|
|
SignOut()
|
|
|
|
return
|
2019-03-19 04:17:50 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "sign_out"
|
|
|
|
SignOut()
|
|
|
|
return
|
2019-03-14 22:20:16 +00:00
|
|
|
else if nodeEventQ(msg, "search_value")
|
2019-03-14 22:50:20 +00:00
|
|
|
query = msg.getRoSGNode().search_value
|
2019-03-16 22:11:50 +00:00
|
|
|
if query <> invalid or query <> ""
|
|
|
|
ShowSearchOptions(query)
|
|
|
|
end if
|
|
|
|
search.search_value = ""
|
2019-03-10 05:28:28 +00:00
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
2019-03-07 03:14:52 +00:00
|
|
|
target = getMsgRowTarget(msg)
|
|
|
|
if target.libraryType = "movies"
|
2019-03-12 23:34:51 +00:00
|
|
|
ShowMovieOptions(target.data)
|
2019-03-11 01:03:45 +00:00
|
|
|
else if target.libraryType = "tvshows"
|
2019-03-12 23:34:51 +00:00
|
|
|
ShowTVShowOptions(target.data)
|
2019-03-20 02:30:08 +00:00
|
|
|
else if target.libraryType = "boxsets"
|
|
|
|
ShowCollections(target.data)
|
2019-03-07 03:14:52 +00:00
|
|
|
else
|
2019-03-20 02:30:08 +00:00
|
|
|
scene.dialog = make_dialog("This library type is not yet implemented: " + target.libraryType)
|
2019-03-17 17:38:21 +00:00
|
|
|
scene.dialog.observeField("buttonSelected", port)
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
2019-03-17 17:38:21 +00:00
|
|
|
else if nodeEventQ(msg, "buttonSelected")
|
|
|
|
if msg.getNode() = "popup"
|
|
|
|
msg.getRoSGNode().close = true
|
|
|
|
end if
|
|
|
|
else
|
|
|
|
print msg
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
sub ShowMovieOptions(library)
|
|
|
|
library_id = library.id
|
2019-03-07 03:14:52 +00:00
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("Movies")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
overhang = scene.findNode("overhang")
|
|
|
|
overhang.title = library.name
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
2019-03-07 03:14:52 +00:00
|
|
|
options = scene.findNode("MovieSelect")
|
2019-03-12 23:34:51 +00:00
|
|
|
options.library = library
|
2019-03-13 01:16:12 +00:00
|
|
|
|
2019-03-12 03:49:17 +00:00
|
|
|
page_num = 1
|
2019-03-13 01:16:12 +00:00
|
|
|
page_size = 30
|
|
|
|
|
|
|
|
sort_order = get_user_setting("movie_sort_order", "Descending")
|
|
|
|
sort_field = get_user_setting("movie_sort_field", "DateCreated,SortName")
|
|
|
|
|
2019-03-12 03:49:17 +00:00
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"StartIndex": page_size * (page_num - 1),
|
2019-03-13 01:16:12 +00:00
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
2019-03-07 03:14:52 +00:00
|
|
|
options.movieData = options_list
|
|
|
|
|
|
|
|
options.observeField("itemSelected", port)
|
|
|
|
|
2019-03-12 03:49:17 +00:00
|
|
|
pager = scene.findNode("pager")
|
|
|
|
pager.currentPage = page_num
|
2019-03-13 01:16:12 +00:00
|
|
|
pager.maxPages = options_list.TotalRecordCount / page_size
|
|
|
|
if pager.maxPages = 0 then pager.maxPages = 1
|
2019-03-12 03:49:17 +00:00
|
|
|
|
|
|
|
pager.observeField("escape", port)
|
|
|
|
pager.observeField("pageSelected", port)
|
|
|
|
|
2019-03-17 23:07:57 +00:00
|
|
|
sidepanel = scene.findNode("options")
|
|
|
|
movie_options = [
|
|
|
|
{"title": "Sort Field",
|
2019-03-18 00:17:54 +00:00
|
|
|
"base_title": "Sort Field",
|
2019-03-17 23:07:57 +00:00
|
|
|
"key": "movie_sort_field",
|
2019-03-18 00:17:54 +00:00
|
|
|
"default": "DateCreated",
|
|
|
|
"values": ["DateCreated", "PremiereDate", "SortName"]},
|
2019-03-17 23:07:57 +00:00
|
|
|
{"title": "Sort Order",
|
2019-03-18 00:17:54 +00:00
|
|
|
"base_title": "Sort Order",
|
2019-03-17 23:07:57 +00:00
|
|
|
"key": "movie_sort_order",
|
2019-03-18 00:17:54 +00:00
|
|
|
"default": "Descending",
|
|
|
|
"values": ["Descending", "Ascending"]}
|
2019-03-17 23:07:57 +00:00
|
|
|
]
|
|
|
|
new_options = []
|
|
|
|
for each opt in movie_options
|
2019-03-18 00:17:54 +00:00
|
|
|
o = CreateObject("roSGNode", "OptionsData")
|
2019-03-17 23:07:57 +00:00
|
|
|
o.title = opt.title
|
2019-03-18 00:17:54 +00:00
|
|
|
o.choices = opt.values
|
|
|
|
o.base_title = opt.base_title
|
|
|
|
o.config_key = opt.key
|
|
|
|
o.value = get_user_setting(opt.key, opt.default)
|
2019-03-17 23:07:57 +00:00
|
|
|
new_options.append([o])
|
|
|
|
end for
|
|
|
|
|
2019-03-19 04:17:50 +00:00
|
|
|
sidepanel.options = new_options
|
2019-03-17 23:07:57 +00:00
|
|
|
sidepanel.observeField("escape", port)
|
|
|
|
|
2019-03-07 03:14:52 +00:00
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
2019-03-12 03:49:17 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
|
|
|
|
options.setFocus(true)
|
2019-03-17 23:07:57 +00:00
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
|
|
|
|
options.setFocus(true)
|
2019-03-12 03:49:17 +00:00
|
|
|
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
|
|
|
|
pager.pageSelected = invalid
|
|
|
|
page_num = int(val(msg.getData().id))
|
|
|
|
pager.currentPage = page_num
|
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"StartIndex": page_size * (page_num - 1),
|
2019-03-13 01:16:12 +00:00
|
|
|
"SortBy": sort_order,
|
|
|
|
"SortOrder": sort_field })
|
2019-03-12 03:49:17 +00:00
|
|
|
options.movieData = options_list
|
|
|
|
options.setFocus(true)
|
2019-03-10 05:28:28 +00:00
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
2019-03-07 03:14:52 +00:00
|
|
|
target = getMsgRowTarget(msg)
|
2019-03-08 03:47:10 +00:00
|
|
|
ShowMovieDetails(target.movieID)
|
2019-03-12 03:49:17 +00:00
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print msg.getField()
|
|
|
|
print msg.getData()
|
2019-03-08 03:47:10 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
|
|
|
sub ShowMovieDetails(movie_id)
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("MovieItemDetailScene")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
2019-03-12 01:24:39 +00:00
|
|
|
content = createObject("roSGNode", "MovieData")
|
2019-03-10 06:12:09 +00:00
|
|
|
content.full_data = ItemMetaData(movie_id)
|
|
|
|
scene.itemContent = content
|
2019-03-08 03:47:10 +00:00
|
|
|
|
2019-03-09 22:23:57 +00:00
|
|
|
buttons = scene.findNode("buttons")
|
2019-03-14 04:09:55 +00:00
|
|
|
for each b in buttons.getChildren(-1, 0)
|
|
|
|
b.observeField("buttonSelected", port)
|
|
|
|
end for
|
2019-03-09 22:23:57 +00:00
|
|
|
|
2019-03-08 03:47:10 +00:00
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
2019-03-10 05:28:28 +00:00
|
|
|
else if nodeEventQ(msg, "buttonSelected")
|
2019-03-14 04:09:55 +00:00
|
|
|
if msg.getNode() = "play-button"
|
2019-03-09 22:23:57 +00:00
|
|
|
showVideoPlayer(movie_id)
|
2019-03-14 04:09:55 +00:00
|
|
|
else if msg.getNode() = "watched-button"
|
2019-03-14 03:01:05 +00:00
|
|
|
if content.watched
|
|
|
|
UnmarkItemWatched(movie_id)
|
|
|
|
else
|
|
|
|
MarkItemWatched(movie_id)
|
|
|
|
end if
|
|
|
|
content.watched = not content.watched
|
2019-03-14 04:09:55 +00:00
|
|
|
else if msg.getNode() = "favorite-button"
|
2019-03-13 03:27:24 +00:00
|
|
|
if content.favorite
|
|
|
|
UnmarkItemFavorite(movie_id)
|
|
|
|
else
|
|
|
|
MarkItemFavorite(movie_id)
|
|
|
|
end if
|
|
|
|
content.favorite = not content.favorite
|
2019-03-09 22:23:57 +00:00
|
|
|
end if
|
2019-03-09 22:09:21 +00:00
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print type(msg)
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
sub ShowTVShowOptions(library)
|
|
|
|
library_id = library.ID
|
2019-03-11 01:03:45 +00:00
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("TVShows")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-12 23:34:51 +00:00
|
|
|
overhang = scene.findNode("overhang")
|
|
|
|
overhang.title = library.name
|
|
|
|
|
2019-03-11 01:03:45 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
|
|
|
options = scene.findNode("TVShowSelect")
|
2019-03-13 01:16:12 +00:00
|
|
|
options.library = library
|
|
|
|
|
|
|
|
page_num = 1
|
|
|
|
page_size = 30
|
|
|
|
|
|
|
|
sort_order = get_user_setting("tvshow_sort_order", "Descending")
|
|
|
|
sort_field = get_user_setting("tvshow_sort_field", "DateCreated,SortName")
|
|
|
|
|
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"page": page_num,
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
|
|
|
options.TVShowData = options_list
|
2019-03-11 01:03:45 +00:00
|
|
|
|
|
|
|
options.observeField("itemSelected", port)
|
|
|
|
|
2019-03-13 01:16:12 +00:00
|
|
|
pager = scene.findNode("pager")
|
|
|
|
pager.currentPage = page_num
|
|
|
|
pager.maxPages = options_list.TotalRecordCount / page_size
|
|
|
|
if pager.maxPages = 0 then pager.maxPages = 1
|
|
|
|
|
|
|
|
pager.observeField("escape", port)
|
|
|
|
pager.observeField("pageSelected", port)
|
|
|
|
|
2019-03-11 01:03:45 +00:00
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
2019-03-13 01:16:12 +00:00
|
|
|
if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
|
|
|
|
options.setFocus(true)
|
|
|
|
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
|
|
|
|
pager.pageSelected = invalid
|
|
|
|
page_num = int(val(msg.getData().id))
|
|
|
|
pager.currentPage = page_num
|
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"StartIndex": page_size * (page_num - 1),
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
|
|
|
options.TVShowData = options_list
|
|
|
|
options.setFocus(true)
|
|
|
|
else if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
2019-03-11 01:03:45 +00:00
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
2019-03-13 01:16:12 +00:00
|
|
|
ShowTVShowDetails(target.showID)
|
2019-03-11 01:03:45 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-11 01:24:50 +00:00
|
|
|
sub ShowTVShowDetails(show_id)
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("TVShowItemDetailScene")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
2019-03-12 01:24:39 +00:00
|
|
|
content = createObject("roSGNode", "TVShowData")
|
2019-03-11 01:24:50 +00:00
|
|
|
content.full_data = ItemMetaData(show_id)
|
|
|
|
scene.itemContent = content
|
2019-03-13 17:20:54 +00:00
|
|
|
x = TVSeasons(show_id)
|
|
|
|
scene.itemContent.seasons = TVSeasons(show_id)
|
2019-03-11 01:24:50 +00:00
|
|
|
|
|
|
|
'buttons = scene.findNode("buttons")
|
|
|
|
'buttons.observeField("buttonSelected", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "buttonSelected")
|
|
|
|
' What button could we even be watching yet
|
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print type(msg)
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-20 02:30:08 +00:00
|
|
|
sub ShowCollections(library)
|
|
|
|
library_id = library.id
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("Collections")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
|
|
|
overhang = scene.findNode("overhang")
|
|
|
|
overhang.title = library.name
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
|
|
|
options = scene.findNode("CollectionSelect")
|
|
|
|
options.library = library
|
|
|
|
|
|
|
|
page_num = 1
|
|
|
|
page_size = 30
|
|
|
|
|
|
|
|
sort_order = get_user_setting("collection_sort_order", "Ascending")
|
|
|
|
sort_field = get_user_setting("collection_sort_field", "SortName")
|
|
|
|
|
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"StartIndex": page_size * (page_num - 1),
|
|
|
|
"SortBy": sort_field,
|
|
|
|
"SortOrder": sort_order })
|
|
|
|
options.itemData = options_list
|
|
|
|
|
|
|
|
options.observeField("itemSelected", port)
|
|
|
|
|
|
|
|
pager = scene.findNode("pager")
|
|
|
|
pager.currentPage = page_num
|
|
|
|
pager.maxPages = options_list.TotalRecordCount / page_size
|
|
|
|
if pager.maxPages = 0 then pager.maxPages = 1
|
|
|
|
|
|
|
|
pager.observeField("escape", port)
|
|
|
|
pager.observeField("pageSelected", port)
|
|
|
|
|
|
|
|
sidepanel = scene.findNode("options")
|
|
|
|
panel_options = [
|
|
|
|
{"title": "Sort Field",
|
|
|
|
"base_title": "Sort Field",
|
|
|
|
"key": "movie_sort_field",
|
|
|
|
"default": "DateCreated",
|
|
|
|
"values": ["DateCreated", "PremiereDate", "SortName"]},
|
|
|
|
{"title": "Sort Order",
|
|
|
|
"base_title": "Sort Order",
|
|
|
|
"key": "movie_sort_order",
|
|
|
|
"default": "Descending",
|
|
|
|
"values": ["Descending", "Ascending"]}
|
|
|
|
]
|
|
|
|
new_options = []
|
|
|
|
for each opt in panel_options
|
|
|
|
o = CreateObject("roSGNode", "OptionsData")
|
|
|
|
o.title = opt.title
|
|
|
|
o.choices = opt.values
|
|
|
|
o.base_title = opt.base_title
|
|
|
|
o.config_key = opt.key
|
|
|
|
o.value = get_user_setting(opt.key, opt.default)
|
|
|
|
new_options.append([o])
|
|
|
|
end for
|
|
|
|
|
|
|
|
sidepanel.options = new_options
|
|
|
|
sidepanel.observeField("escape", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "pager"
|
|
|
|
options.setFocus(true)
|
|
|
|
else if nodeEventQ(msg, "escape") and msg.getNode() = "options"
|
|
|
|
options.setFocus(true)
|
|
|
|
else if nodeEventQ(msg, "pageSelected") and pager.pageSelected <> invalid
|
|
|
|
pager.pageSelected = invalid
|
|
|
|
page_num = int(val(msg.getData().id))
|
|
|
|
pager.currentPage = page_num
|
|
|
|
options_list = ItemList(library_id, {"limit": page_size,
|
|
|
|
"StartIndex": page_size * (page_num - 1),
|
|
|
|
"SortBy": sort_order,
|
|
|
|
"SortOrder": sort_field })
|
|
|
|
options.itemData = options_list
|
|
|
|
options.setFocus(true)
|
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
|
|
|
ShowMovieOptions(target)
|
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print msg.getField()
|
|
|
|
print msg.getData()
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-14 22:50:20 +00:00
|
|
|
sub ShowSearchOptions(query)
|
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("SearchResults")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
|
|
|
themeScene(scene)
|
|
|
|
|
|
|
|
options = scene.findNode("SearchSelect")
|
|
|
|
|
|
|
|
sort_order = get_user_setting("search_sort_order", "Descending")
|
|
|
|
sort_field = get_user_setting("search_sort_field", "DateCreated,SortName")
|
|
|
|
|
|
|
|
results = SearchMedia(query)
|
|
|
|
options.itemData = results
|
|
|
|
options.query = query
|
|
|
|
|
|
|
|
options.observeField("itemSelected", port)
|
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
|
|
|
return
|
|
|
|
else if nodeEventQ(msg, "itemSelected")
|
|
|
|
target = getMsgRowTarget(msg)
|
|
|
|
' TODO - swap this based on target.mediatype
|
|
|
|
' types: [ Episode, Movie, Audio, Person, Studio, MusicArtist ]
|
|
|
|
ShowMovieDetails(target.mediaID)
|
|
|
|
else
|
|
|
|
print msg
|
|
|
|
print msg.getField()
|
|
|
|
print msg.getData()
|
|
|
|
end if
|
|
|
|
end while
|
|
|
|
end sub
|
|
|
|
|
2019-03-19 00:33:44 +00:00
|
|
|
sub showVideoPlayer(video_id)
|
2019-03-07 03:14:52 +00:00
|
|
|
port = CreateObject("roMessagePort")
|
|
|
|
screen = CreateObject("roSGScreen")
|
|
|
|
screen.setMessagePort(port)
|
|
|
|
scene = screen.CreateScene("Scene")
|
|
|
|
|
|
|
|
screen.show()
|
|
|
|
|
2019-03-10 05:28:28 +00:00
|
|
|
themeScene(scene)
|
|
|
|
|
2019-03-19 00:33:44 +00:00
|
|
|
video = VideoPlayer(video_id)
|
|
|
|
scene.appendChild(video)
|
|
|
|
|
|
|
|
video.setFocus(true)
|
|
|
|
|
|
|
|
video.observeField("state", port)
|
2019-03-07 03:14:52 +00:00
|
|
|
|
|
|
|
while true
|
|
|
|
msg = wait(0, port)
|
|
|
|
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
2019-03-20 02:36:59 +00:00
|
|
|
return
|
|
|
|
' Video is already gone by this point
|
2019-03-19 02:59:23 +00:00
|
|
|
' TODO - add an event listener higher up that watches for closing
|
|
|
|
' so we can handle end of video a bit better
|
2019-03-19 01:11:34 +00:00
|
|
|
if video = invalid then return
|
|
|
|
|
2019-03-19 00:33:44 +00:00
|
|
|
progress = int( video.position / video.duration * 100)
|
|
|
|
if progress > 95 ' TODO - max resume percentage
|
|
|
|
MarkItemWatched(video_id)
|
|
|
|
end if
|
2019-03-19 01:11:34 +00:00
|
|
|
ticks = video.position * 10000000
|
|
|
|
ItemSessionStop(video_id, {"PositionTicks": ticks})
|
2019-03-07 03:14:52 +00:00
|
|
|
return
|
2019-03-19 00:33:44 +00:00
|
|
|
else if nodeEventQ(msg, "state")
|
|
|
|
state = msg.getData()
|
|
|
|
if state = "stopped" or state = "finished"
|
|
|
|
screen.close()
|
2019-03-19 01:11:34 +00:00
|
|
|
else if state = "playing"
|
|
|
|
ticks = video.position * 10000000
|
|
|
|
ItemSessionStart(video_id, {"PositionTicks": ticks})
|
2019-03-19 00:33:44 +00:00
|
|
|
end if
|
2019-03-07 03:14:52 +00:00
|
|
|
end if
|
|
|
|
end while
|
|
|
|
|
|
|
|
end sub
|