Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release_state
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2a7b09b293a17369def2bd4d479dadf1fc6bd955
f87d0125f247d6a82487bb7fbce6825a39dad51a
10 changes: 10 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"indentation" : {
"spaces" : 2
},
"lineLength" : 120,
"maximumBlankLines" : 1,
"respectsExistingLineBreaks" : true,
"tabWidth" : 2,
"version" : 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "closed_caption.png",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions ABPlayer/Sources/ViewModels/VideoPlayerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ final class VideoPlayerViewModel {
var seekValue: Double = 0
var wasPlayingBeforeSeek: Bool = false

// MARK: - HUD
var hudMessage: String?
var hideHudTask: Task<Void, Never>?
var showHudMessage: Bool {
guard let hudMessage else {
return false
}
return !hudMessage.isEmpty
}

// MARK: - Layout State
var draggingWidth: Double?

Expand Down Expand Up @@ -113,12 +123,14 @@ final class VideoPlayerViewModel {
guard let manager = playerManager else { return }
let targetTime = manager.currentTime - 5
manager.seek(to: targetTime)
showHUDMessage("- 5")
}

func seekForward() {
guard let manager = playerManager else { return }
let targetTime = manager.currentTime + 10
manager.seek(to: targetTime)
showHUDMessage("+ 10s")
}

func timeString(from value: Double) -> String {
Expand All @@ -138,4 +150,26 @@ final class VideoPlayerViewModel {

return String(format: "%d:%02d", minutes, seconds)
}

func showHUDMessage(_ message: String) {
hideHudTask?.cancel()
hudMessage = nil

Task { @MainActor in
try? await Task.sleep(nanoseconds: 10_000_000)
withAnimation(.bouncy) {
hudMessage = message
}

hideHudTask = Task {
try? await Task.sleep(nanoseconds: 2_000_000_000)
if Task.isCancelled {
return
}
withAnimation {
hudMessage = nil
}
}
}
}
}
1 change: 0 additions & 1 deletion ABPlayer/Sources/Views/Components/SegmentsSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct SegmentsSection: View {

var body: some View {
VStack(alignment: .leading, spacing: 8) {

HStack {
// Loop Controls Group
HStack {
Expand Down
47 changes: 37 additions & 10 deletions ABPlayer/Sources/Views/Components/VideoControlsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ import Observation
struct VideoControlsView: View {
@Bindable var viewModel: VideoPlayerViewModel
@Environment(AudioPlayerManager.self) private var playerManager
@State private var showSubtitle = false

var body: some View {
ZStack(alignment: .center) {
HStack {
// Loop Mode & Volume
HStack(spacing: 12) {
VideoTimeDisplay(isSeeking: viewModel.isSeeking, seekValue: viewModel.seekValue)

Spacer()

HStack {
loopModeMenu

Button {
showSubtitle.toggle()
} label: {
Image(.closedCaption).renderingMode(.template).resizable().aspectRatio(contentMode: .fit).frame(width: 24)
}
.buttonStyle(.plain)
.foregroundStyle(showSubtitle ? Color.accentColor : .primary)

VolumeControl(playerVolume: $viewModel.playerVolume)
}

Spacer()

VideoTimeDisplay(isSeeking: viewModel.isSeeking, seekValue: viewModel.seekValue)
}

// Playback Controls
Expand All @@ -39,18 +48,27 @@ struct VideoControlsView: View {
} label: {
Image(
systemName: playerManager.loopMode != .none
? "\(playerManager.loopMode.iconName).circle.fill"
: "repeat.circle"
? "\(playerManager.loopMode.iconName)"
: "repeat"
)
.font(.title)
.foregroundStyle(playerManager.loopMode != .none ? .blue : .primary)
.font(.title2)
.foregroundStyle(playerManager.loopMode != .none ? Color.accentColor : .primary)
}
.buttonStyle(.plain)
.help("Loop mode: \(playerManager.loopMode.displayName)")
}

private var playbackControls: some View {
HStack(spacing: 16) {
Button {
// switch to previous item
} label: {
Image(systemName: "backward.end")
.font(.title)
}
.buttonStyle(.plain)
.keyboardShortcut("f", modifiers: [])

Button {
viewModel.seekBack()
} label: {
Expand All @@ -77,6 +95,15 @@ struct VideoControlsView: View {
}
.buttonStyle(.plain)
.keyboardShortcut("g", modifiers: [])

Button {
// switch to next item
} label: {
Image(systemName: "forward.end")
.font(.title)
}
.buttonStyle(.plain)
.keyboardShortcut("f", modifiers: [])
}
}
}
39 changes: 27 additions & 12 deletions ABPlayer/Sources/Views/VideoPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,33 @@ struct VideoPlayerView: View {
private var videoSection: some View {
VStack(alignment: .leading, spacing: 0) {
// 1. Video Player Area
Group {
if let player = playerManager.player {
NativeVideoPlayer(player: player)
} else {
ZStack {
Color.black
ProgressView()
.scaleEffect(1.5)
.tint(.white)
ZStack {
Group {
if let player = playerManager.player {
NativeVideoPlayer(player: player)
} else {
ZStack {
Color.black
ProgressView()
.scaleEffect(1.5)
.tint(.white)
}
}
}
.aspectRatio(16 / 9, contentMode: .fit)
.layoutPriority(1)

if viewModel.showHudMessage {
Text(viewModel.hudMessage ?? "")
.font(.title)
.padding(.all, 16)
.background(.black.opacity(0.6))
.cornerRadius(8)
.id(viewModel.hudMessage)
.transition(.scale.combined(with: .opacity))
.animation(.bouncy, value: viewModel.hudMessage)
}
}
.aspectRatio(16 / 9, contentMode: .fit)
.layoutPriority(1)

// 2. Controls Area (Fixed height)
VStack(spacing: 12) {
Expand All @@ -150,8 +163,10 @@ struct VideoPlayerView: View {
)

VideoControlsView(viewModel: viewModel)

.padding(.horizontal)

Divider()

ContentPanelView(audioFile: audioFile)
}
}
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [0.2.9.58] - 2026-01-19

### Features
- add HUD feedback, subtitle toggle, and track navigation controls

### Chores
- refine VideoPlayerView layout and SegmentsSection spacing


## [0.2.9.57] - 2026-01-19

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ProjectDescription

let buildVersionString = "57"
let buildVersionString = "58"
let shortVersionString = "0.2.9"
let project = Project(
name: "ABPlayer",
Expand Down