Adjust album view

This commit is contained in:
1hitsong 2022-10-02 14:23:42 -04:00
parent 5f4fb2239f
commit f257a3195a
8 changed files with 102 additions and 25 deletions

View File

@ -80,6 +80,20 @@ sub itemContentChanged()
m.backdrop.height = 290 m.backdrop.height = 290
m.backdrop.width = 290 m.backdrop.width = 290
m.posterText.height = 200
m.posterText.width = 280
else if itemData.json.type = "MusicAlbum"
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
m.itemPoster.height = 290
m.itemPoster.width = 290
m.itemText.translation = [0, m.itemPoster.height + 7]
m.backdrop.height = 290
m.backdrop.width = 290
m.posterText.height = 200 m.posterText.height = 200
m.posterText.width = 280 m.posterText.width = 280
else else

View File

@ -303,7 +303,6 @@ end sub
' Set Music view, sort, and filter options ' Set Music view, sort, and filter options
sub setMusicOptions(options) sub setMusicOptions(options)
options.views = [ options.views = [
{ "Title": tr("Default"), "Name": "music-default" },
{ "Title": tr("Artists"), "Name": "music-artist" }, { "Title": tr("Artists"), "Name": "music-artist" },
{ "Title": tr("Albums"), "Name": "music-album" }, { "Title": tr("Albums"), "Name": "music-album" },
] ]
@ -590,13 +589,7 @@ sub optionsClosed()
if m.top.parentItem.collectionType = "music" if m.top.parentItem.collectionType = "music"
if m.options.view <> m.view if m.options.view <> m.view
if m.options.view = "music-artist" m.view = m.options.view
m.view = "music-artist"
else if m.options.view = "music-album"
m.view = "music-album"
else
m.view = "music-default"
end if
set_user_setting("display.music.view", m.view) set_user_setting("display.music.view", m.view)
reload = true reload = true
end if end if
@ -787,6 +780,12 @@ sub updateTitle()
m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")" m.top.overhangTitle = m.top.parentItem.title + tr(" (Filtered by ") + m.loadItemsTask.nameStartsWith + ")"
end if end if
if m.view = "music-artist"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Artists"))
else if m.view = "music-album"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Albums"))
end if
if m.options.view = "Networks" or m.view = "Networks" if m.options.view = "Networks" or m.view = "Networks"
m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Networks")) m.top.overhangTitle = "%s (%s)".Format(m.top.parentItem.title, tr("Networks"))
end if end if

View File

@ -83,6 +83,10 @@ sub loadItems()
UserId: get_setting("active_user") UserId: get_setting("active_user")
}) })
params.IncludeItemTypes = "" params.IncludeItemTypes = ""
else if m.top.ItemType = "MusicAlbum"
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
params.append({ ImageTypeLimit: 1 })
params.append({ EnableImageTypes: "Primary,Backdrop,Banner,Thumb" })
else else
url = Substitute("Users/{0}/Items/", get_setting("active_user")) url = Substitute("Users/{0}/Items/", get_setting("active_user"))
end if end if
@ -118,6 +122,12 @@ sub loadItems()
tmp = CreateObject("roSGNode", "FolderData") tmp = CreateObject("roSGNode", "FolderData")
else if item.Type = "MusicAlbum" else if item.Type = "MusicAlbum"
tmp = CreateObject("roSGNode", "MusicAlbumData") tmp = CreateObject("roSGNode", "MusicAlbumData")
tmp.type = "MusicAlbum"
if api_API().items.headimageurlbyname(item.id, "primary")
tmp.posterURL = ImageURL(item.id, "Primary")
else
tmp.posterURL = ImageURL(item.id, "backdrop")
end if
else if item.Type = "MusicArtist" else if item.Type = "MusicArtist"
tmp = CreateObject("roSGNode", "MusicArtistData") tmp = CreateObject("roSGNode", "MusicArtistData")
else if item.Type = "Audio" else if item.Type = "Audio"

View File

@ -22,6 +22,7 @@
</interface> </interface>
<script type="text/brightscript" uri="LoadItemsTask2.brs" /> <script type="text/brightscript" uri="LoadItemsTask2.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Items.brs" /> <script type="text/brightscript" uri="pkg:/source/api/Items.brs" />
<script type="text/brightscript" uri="pkg:/source/roku_modules/api/api.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" /> <script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" /> <script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Image.brs" /> <script type="text/brightscript" uri="pkg:/source/api/Image.brs" />

View File

@ -812,5 +812,10 @@
<translation>WxH</translation> <translation>WxH</translation>
<extracomment>Video width x height</extracomment> <extracomment>Video width x height</extracomment>
</message> </message>
<message>
<source>Unable to find any albums or songs belonging to this artist</source>
<translation>Unable to find any albums or songs belonging to this artist</translation>
<extracomment>Popup message when we find no audio data for an artist</extracomment>
</message>
</context> </context>
</TS> </TS>

View File

@ -159,6 +159,9 @@ sub Main (args as dynamic) as void
' Nothing to do here, handled in ItemGrid ' Nothing to do here, handled in ItemGrid
else if selectedItem.type = "MusicArtist" else if selectedItem.type = "MusicArtist"
group = CreateArtistView(selectedItem.json) group = CreateArtistView(selectedItem.json)
if not isValid(group)
message_dialog(tr("Unable to find any albums or songs belonging to this artist"))
end if
else if selectedItem.type = "MusicAlbum" else if selectedItem.type = "MusicAlbum"
group = CreateAlbumView(selectedItem.json) group = CreateAlbumView(selectedItem.json)
else if selectedItem.type = "Audio" else if selectedItem.type = "Audio"

View File

@ -383,7 +383,20 @@ function CreateArtistView(musicartist)
' Just songs under artists... ' Just songs under artists...
group = CreateObject("roSGNode", "AlbumView") group = CreateObject("roSGNode", "AlbumView")
group.pageContent = ItemMetaData(musicartist.id) group.pageContent = ItemMetaData(musicartist.id)
group.albumData = MusicSongList(musicartist.id)
' Lookup songs based on artist id
songList = GetSongsByArtist(musicartist.id)
if not isValid(songList)
' Lookup songs based on folder parent / child relationship
songList = MusicSongList(musicartist.id)
end if
if not isValid(songList)
return invalid
end if
group.albumData = songList
group.observeField("playSong", m.port) group.observeField("playSong", m.port)
group.observeField("playAllSelected", m.port) group.observeField("playAllSelected", m.port)
group.observeField("instantMixSelected", m.port) group.observeField("instantMixSelected", m.port)

View File

@ -219,6 +219,33 @@ function AppearsOnList(id as string)
return data return data
end function end function
' Get list of songs belonging to an artist
function GetSongsByArtist(id as string)
url = Substitute("Users/{0}/Items", get_setting("active_user"))
resp = APIRequest(url, {
"AlbumArtistIds": id,
"includeitemtypes": "Audio",
"sortBy": "SortName",
"Recursive": true
})
data = getJson(resp)
results = []
if data = invalid then return invalid
if data.Items = invalid then return invalid
if data.Items.Count() = 0 then return invalid
for each item in data.Items
tmp = CreateObject("roSGNode", "MusicAlbumData")
tmp.image = PosterImage(item.id)
tmp.json = item
results.push(tmp)
end for
data.Items = results
return data
end function
' Get Songs that are on an Album ' Get Songs that are on an Album
function MusicSongList(id as string) function MusicSongList(id as string)
url = Substitute("Users/{0}/Items", get_setting("active_user"), id) url = Substitute("Users/{0}/Items", get_setting("active_user"), id)
@ -229,8 +256,13 @@ function MusicSongList(id as string)
"sortBy": "SortName" "sortBy": "SortName"
}) })
data = getJson(resp)
results = [] results = []
data = getJson(resp)
if data = invalid then return invalid
if data.Items = invalid then return invalid
if data.Items.Count() = 0 then return invalid
for each item in data.Items for each item in data.Items
tmp = CreateObject("roSGNode", "MusicSongData") tmp = CreateObject("roSGNode", "MusicSongData")
tmp.image = PosterImage(item.id) tmp.image = PosterImage(item.id)