Skip to content

Commit

Permalink
Multiple bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Oct 4, 2023
1 parent af2607a commit 694adf1
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- (potentionally) a bug where many dialogs could cause an execution timeout
- Mutltiple rare crashes when component content is set before component initialization

## [0.13.0] - 2023-10-02

Expand Down
3 changes: 2 additions & 1 deletion playlet-lib/src/components/ChannelView/ChannelView.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
id="thumbnail"
width="100"
height="100"
translation="[2,2]" />
translation="[2,2]"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />

<Label
id="authorLabel"
Expand Down
7 changes: 3 additions & 4 deletions playlet-lib/src/components/CirclePoster/CirclePoster.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ function Init()
end function

function UpdateMaskSize()
width = m.top.poster.width
height = m.top.poster.height
width = m.top.width
height = m.top.height

maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
m.top.maskGroup.maskSize = maskSize
m.top.maskSize = [width * GetScaleFactor(), height * GetScaleFactor()]
end function

' MaskGroup component do not scale with with UI resolution
Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/CirclePoster/CirclePoster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field id="loadStatus" type="string" alias="Poster.loadStatus" />

<field id="maskUri" type="uri" value="pkg:/images/circle-mask-500.png" alias="MaskGroup.maskuri" />
<field id="maskSize" type="vector2d" alias="MaskGroup.maskSize" />
</interface>
<children>
<MaskGroup
Expand Down
1 change: 1 addition & 0 deletions playlet-lib/src/components/MainScene.transpiled.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<script type="text/brightscript" uri="pkg:/source/utils/StringUtils.brs" />
<script type="text/brightscript" uri="pkg:/components/VideoPlayer/VideoUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/FocusManagement.brs" />
<script type="text/brightscript" uri="pkg:/components/Dialog/DialogUtils.brs" />
<script type="text/brightscript" uri="pkg:/source/bslib.brs" />
<children>
<AppController id="AppController">
Expand Down
10 changes: 8 additions & 2 deletions playlet-lib/src/components/PlaylistView/PlaylistViewCell.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"

function Init()
FindChildren()
end function

function FindChildren()
m.titleLabel = m.top.findNode("titleLabel")
m.authorLabel = m.top.findNode("authorLabel")
m.thumbnail = m.top.findNode("thumbnail")
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")

m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function

function OnContentSet() as void
Expand All @@ -18,6 +20,10 @@ function OnContentSet() as void
return
end if

if m.titleLabel = invalid
FindChildren()
end if

m.titleLabel.text = content.title
m.authorLabel.text = content.author

Expand Down
3 changes: 2 additions & 1 deletion playlet-lib/src/components/PlaylistView/PlaylistViewCell.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="190"
height="106">
height="106"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="durationRect"
width="60"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
function Init()
m.authorLabel = m.top.FindNode("authorLabel")
m.subCountLabel = m.top.FindNode("subCountLabel")
m.videoCountLabel = m.top.FindNode("videoCountLabel")
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function

function OnContentSet() as void
content = m.top.itemContent

Expand All @@ -14,8 +6,8 @@ function OnContentSet() as void
end if

' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.authorLabel.text = content._author
m.subCountLabel.text = content.subCountText
m.videoCountLabel.text = content.videoCountText
m.thumbnail.uri = content.thumbnail
m.top._author = content._author
m.top.subCountText = content.subCountText
m.top.videoCountText = content.videoCountText
m.top.thumbnail = content.thumbnail
end function
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<component name="ChannelRowCell" extends="Group">
<interface>
<field id="itemContent" type="node" onChange="OnContentSet" />
<field id="type" type="string" value="channel" />
<field id="_author" type="string" alias="authorLabel.text" />
<field id="subCountText" type="string" alias="subCountLabel.text" />
<field id="videoCountText" type="string" alias="videoCountLabel.text" />
<field id="thumbnail" type="uri" alias="thumbnail.uri" />
<field id="itemContent" type="node" onChange="OnContentSet" />
</interface>
<children>
<LayoutGroup
Expand All @@ -10,7 +14,8 @@
<CirclePoster
id="thumbnail"
width="196"
height="196" />
height="196"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg" />

<Label
id="authorLabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"

function Init()
FindChildren()
end function

function FindChildren()
m.titleLabel = m.top.FindNode("titleLabel")
m.authorLabel = m.top.FindNode("authorLabel")
m.viewCountDateLabel = m.top.FindNode("viewCountDateLabel")
Expand All @@ -11,7 +15,6 @@ function Init()
m.durationRect = m.top.FindNode("durationRect")
m.durationLabel = m.top.FindNode("durationLabel")
m.thumbnail = m.top.FindNode("thumbnail")
m.thumbnail.failedBitmapUri = "pkg:/images/thumbnail-missing.jpg"
end function

function OnContentSet() as void
Expand All @@ -21,6 +24,10 @@ function OnContentSet() as void
return
end if

if m.titleLabel = invalid
FindChildren()
end if

m.titleLabel.text = content.title
m.authorLabel.text = content.author

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
id="thumbnail"
loadDisplayMode="scaleToZoom"
width="350"
height="196">
height="196"
failedBitmapUri="pkg:/images/thumbnail-missing.jpg">
<Rectangle
id="durationRect"
width="60"
Expand Down
12 changes: 12 additions & 0 deletions playlet-lib/src/components/VideoPlayer/VideoUtils.bs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "pkg:/components/Dialog/DialogUtils.bs"
import "pkg:/source/utils/FocusManagement.bs"
import "pkg:/source/utils/StringUtils.bs"

Expand All @@ -6,6 +7,17 @@ namespace VideoUtils
CloseVideo(false)

container = GetVideoContainer()
' There should be no reason for this to be invalid, but there was a crash report
' with this being invalid, so we'll abort playing a video and try to restore focus to the top screen
if container = invalid
LogError("VideoContainer not found! Attempting to restore focus to top screen...")
appController = m.top.getScene().findNode("AppController")
if appController <> invalid
appController@.FocusTopScreen(invalid)
end if
DialogUtils.ShowDialog(`VideoContainer not found!\nPlease try again. If the problem persist, contact Playlet authors.`, "Error playing video")
return
end if
videoPlayer = container.createChild("videoPlayer")
videoPlayer.id = "VideoPlayer"
videoPlayer@.BindNode(invalid)
Expand Down

0 comments on commit 694adf1

Please sign in to comment.