auto play on tvOS

This commit is contained in:
Ethan Pippin 2022-01-02 21:48:18 -07:00
parent 47249c2edd
commit a9d37033e6
5 changed files with 20 additions and 11 deletions

View File

@ -75,7 +75,7 @@ struct tvOSOverlayContentView_Previews: PreviewProvider {
overlayType: .compact,
shouldShowPlayPreviousItem: true,
shouldShowPlayNextItem: true,
shouldShowAutoPlayNextItem: true)
shouldShowAutoPlay: true)
static var previews: some View {
ZStack {

View File

@ -55,7 +55,6 @@ struct tvOSVLCOverlay: View {
Spacer()
if viewModel.shouldShowPlayPreviousItem {
SFSymbolButton(systemName: "chevron.left.circle", action: {
viewModel.playerOverlayDelegate?.didSelectPlayPreviousItem()
@ -74,6 +73,18 @@ struct tvOSVLCOverlay: View {
.foregroundColor(viewModel.nextItemVideoPlayerViewModel == nil ? .gray : .white)
}
if viewModel.shouldShowAutoPlay {
Button {
viewModel.autoplayEnabled.toggle()
} label: {
if viewModel.autoplayEnabled {
Image(systemName: "play.circle.fill")
} else {
Image(systemName: "stop.circle")
}
}
}
if !viewModel.subtitleStreams.isEmpty {
if viewModel.subtitlesEnabled {
SFSymbolButton(systemName: "captions.bubble.fill") {
@ -140,7 +151,7 @@ struct tvOSVLCOverlay_Previews: PreviewProvider {
overlayType: .compact,
shouldShowPlayPreviousItem: true,
shouldShowPlayNextItem: true,
shouldShowAutoPlayNextItem: true)
shouldShowAutoPlay: true)
static var previews: some View {
ZStack {

View File

@ -88,7 +88,7 @@ struct VLCPlayerOverlayView: View {
.foregroundColor(viewModel.nextItemVideoPlayerViewModel == nil ? .gray : .white)
}
if viewModel.shouldShowAutoPlayNextItem {
if viewModel.shouldShowAutoPlay {
Button {
viewModel.autoplayEnabled.toggle()
} label: {
@ -337,7 +337,7 @@ struct VLCPlayerCompactOverlayView_Previews: PreviewProvider {
overlayType: .compact,
shouldShowPlayPreviousItem: true,
shouldShowPlayNextItem: true,
shouldShowAutoPlayNextItem: true)
shouldShowAutoPlay: true)
static var previews: some View {
ZStack {

View File

@ -116,7 +116,7 @@ extension BaseItemDto {
overlayType: overlayType,
shouldShowPlayPreviousItem: shouldShowPlayPreviousItem,
shouldShowPlayNextItem: shouldShowPlayNextItem,
shouldShowAutoPlayNextItem: shouldShowAutoPlay)
shouldShowAutoPlay: shouldShowAutoPlay)
return videoPlayerViewModel
})

View File

@ -53,7 +53,7 @@ final class VideoPlayerViewModel: ViewModel {
let shouldShowPlayPreviousItem: Bool
let shouldShowPlayNextItem: Bool
let shouldShowAutoPlayNextItem: Bool
let shouldShowAutoPlay: Bool
// MARK: General
let item: BaseItemDto
@ -104,9 +104,7 @@ final class VideoPlayerViewModel: ViewModel {
overlayType: OverlayType,
shouldShowPlayPreviousItem: Bool,
shouldShowPlayNextItem: Bool,
shouldShowAutoPlayNextItem: Bool
) {
shouldShowAutoPlay: Bool) {
self.item = item
self.title = title
self.subtitle = subtitle
@ -122,7 +120,7 @@ final class VideoPlayerViewModel: ViewModel {
self.overlayType = overlayType
self.shouldShowPlayPreviousItem = shouldShowPlayPreviousItem
self.shouldShowPlayNextItem = shouldShowPlayNextItem
self.shouldShowAutoPlayNextItem = shouldShowAutoPlayNextItem
self.shouldShowAutoPlay = shouldShowAutoPlay
self.jumpBackwardLength = Defaults[.videoPlayerJumpBackward]
self.jumpForwardLength = Defaults[.videoPlayerJumpForward]