Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
xjbeta committed Dec 3, 2024
2 parents dd0d4df + d89279a commit 756bb7c
Show file tree
Hide file tree
Showing 32 changed files with 436 additions and 354 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ on:

jobs:
release-osx:
runs-on: macos-13
runs-on: macos-15
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
ditto -c -k --sequesterRsrc --keepParent ../../dSYMs dSYMs.zip
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: "!startsWith(github.ref, 'refs/tags/')"
with:
name: archive
Expand Down Expand Up @@ -97,5 +97,5 @@ jobs:
cd AppUpdaterAppcasts
# git checkout -b ci-test
git add -A
git commit -m "$(basename ../archive/NeteaseMusic.xcarchive/Products/Applications/*.zip zip)"
git commit -m "$(basename ../archive/NeteaseMusic.xcarchive/Products/Applications/*.dmg dmg)"
git push https://${{ secrets.PAT }}@github.com/xjbeta/AppUpdaterAppcasts.git
4 changes: 2 additions & 2 deletions NeteaseMusic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.1.4;
MARKETING_VERSION = 0.1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.xjbeta.NeteaseMusic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1147,7 +1147,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 0.1.4;
MARKETING_VERSION = 0.1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.xjbeta.NeteaseMusic;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 4 additions & 0 deletions NeteaseMusic/Utils/NeteaseMusicAPI/NeteaseMusicAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ class NeteaseMusicAPI: NSObject {
[:],
Result.self).map {
$0.profile
}.get {
if self.uid == -1, let id = $0?.userId {
self.uid = id
}
}
}

Expand Down
69 changes: 68 additions & 1 deletion NeteaseMusic/Utils/PlayCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PlayCore: NSObject {
private override init() {
player = AVPlayer()
player.automaticallyWaitsToMinimizeStalling = false
VideoPreloadManager.shared.preloadByteCount *= 2
super.init()
initPlayerObservers()
}
Expand Down Expand Up @@ -64,6 +65,9 @@ class PlayCore: NSObject {
var timeControlStautsObserver: NSKeyValueObservation?


private var playerReloadTimer: Timer?
private var isTryingToReload = false

var playerShouldNextObserver: NSObjectProtocol?
var playerStateObserver: NSKeyValueObservation?

Expand Down Expand Up @@ -410,6 +414,7 @@ class PlayCore: NSObject {
preloadUrls.append(u)
}
}

let vpm = VideoPreloadManager.shared
vpm.set(waiting: preloadUrls)
}.catch {
Expand Down Expand Up @@ -536,6 +541,54 @@ class PlayCore: NSObject {
initInternalPlaylist(currentTrack?.id ?? -1)
}

func startPlayerReloadTimer() {
print("startPlayerReloadTimer")
playerReloadTimer?.invalidate()
playerReloadTimer = Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { [weak self] timer in
guard let self,
player.timeControlStatus == .waitingToPlayAtSpecifiedRate else {
self?.stopPlayerReloadTimer()
return
}

print("Player reloading")

guard let manager = api.reachabilityManager,
manager.isReachable,
let track = currentTrack,
let song = track.song,
let url = song.url?.https else {
return
}

let time = player.currentItem?.currentTime()

playerQueue.async {
let item = AVPlayerItem(loader: url)
item.canUseNetworkResourcesForLiveStreamingWhilePaused = true

DispatchQueue.main.async {
self.player.replaceCurrentItem(with: item)
if let time {
self.player.seek(to: time)
}

self.player.play()
self.playerState = .playing
self.initNowPlayingInfo()
}
}
}
self.isTryingToReload = true
}

func stopPlayerReloadTimer() {
print("stopPlayerReloadTimer")
playerReloadTimer?.invalidate()
playerReloadTimer = nil
isTryingToReload = false
}

// MARK: - System Media Keys

func setupSystemMediaKeys() {
Expand All @@ -550,8 +603,22 @@ class PlayCore: NSObject {

// MARK: - Observers
func initPlayerObservers() {

timeControlStautsObserver = player.observe(\.timeControlStatus, options: [.initial, .new]) { [weak self] (player, changes) in
self?.timeControlStatus = player.timeControlStatus

guard let self else { return }

let newStatus = player.timeControlStatus

if newStatus == .waitingToPlayAtSpecifiedRate {
if !isTryingToReload {
startPlayerReloadTimer()
}
} else if isTryingToReload {
stopPlayerReloadTimer()
}

timeControlStatus = newStatus
}

let timeScale = CMTimeScale(NSEC_PER_SEC)
Expand Down
22 changes: 11 additions & 11 deletions NeteaseMusic/View/AlbumArtistTableView.storyboard
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="aAV-Fa-brE">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="aAV-Fa-brE">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Album Artist Table View Controller-->
<scene sceneID="P4E-Wn-3sg">
<objects>
<viewController id="aAV-Fa-brE" customClass="AlbumArtistTableViewController" customModule="NeteaseMusic" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="aAV-Fa-brE" customClass="AlbumArtistTableViewController" customModule="Netease_Music" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="N9v-SD-vWA">
<rect key="frame" x="0.0" y="0.0" width="820" height="450"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="82" horizontalPageScroll="10" verticalLineScroll="82" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="LVb-h9-Rje" customClass="UnresponsiveScrollView" customModule="NeteaseMusic" customModuleProvider="target">
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="82" horizontalPageScroll="10" verticalLineScroll="82" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="LVb-h9-Rje" customClass="UnresponsiveScrollView" customModule="Netease_Music" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="820" height="450"/>
<clipView key="contentView" id="DnV-yJ-yXC">
<rect key="frame" x="0.0" y="0.0" width="820" height="450"/>
Expand Down Expand Up @@ -77,7 +77,7 @@
<stackView distribution="fill" orientation="horizontal" alignment="bottom" spacing="12" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Srg-cC-A5t">
<rect key="frame" x="100" y="31" width="250" height="19"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TZS-gO-e6d">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TZS-gO-e6d">
<rect key="frame" x="-2" y="0.0" width="42" height="19"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" title="name" id="Zxf-S7-LQC">
<font key="font" metaFont="label" size="15"/>
Expand All @@ -88,7 +88,7 @@
<binding destination="Zf0-Ka-YCC" name="value" keyPath="objectValue.name" id="3h8-og-6wz"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ijh-RE-nCg">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ijh-RE-nCg">
<rect key="frame" x="48" y="0.0" width="204" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="kAY-MI-CEK"/>
Expand Down Expand Up @@ -140,7 +140,7 @@
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="Elk-3H-2Ua"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Dxi-yV-MWY">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Dxi-yV-MWY">
<rect key="frame" x="70" y="21" width="375" height="19"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" title="name" id="VFV-FB-1X8">
<font key="font" metaFont="label" size="15"/>
Expand All @@ -151,7 +151,7 @@
<binding destination="BaK-fz-YRs" name="value" keyPath="objectValue.name" id="Dht-lP-9cF"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fxe-yu-lff">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fxe-yu-lff">
<rect key="frame" x="453" y="22" width="104" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="2gq-Pm-tk8"/>
Expand All @@ -169,7 +169,7 @@
</binding>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="r3E-58-vFs" userLabel="by xxx">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="r3E-58-vFs" userLabel="by xxx">
<rect key="frame" x="565" y="22" width="204" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="Zdu-Ci-jZe"/>
Expand Down Expand Up @@ -222,7 +222,7 @@
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="XiJ-Bj-1Y1"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Nqb-Kz-iPO">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Nqb-Kz-iPO">
<rect key="frame" x="70" y="21" width="42" height="19"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" title="name" id="hPD-N6-mee">
<font key="font" metaFont="label" size="15"/>
Expand All @@ -233,7 +233,7 @@
<binding destination="o89-u5-2IW" name="value" keyPath="objectValue.name" id="zdM-6Y-8SI"/>
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KT8-Xz-cgu">
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KT8-Xz-cgu">
<rect key="frame" x="120" y="22" width="84" height="16"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="left" title="secondName" id="LlN-FR-c24">
<font key="font" metaFont="system"/>
Expand Down
6 changes: 3 additions & 3 deletions NeteaseMusic/View/ArtistButtons.storyboard
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="bU7-R8-ocO">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="bU7-R8-ocO">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23504"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Artist Buttons View Controller-->
<scene sceneID="PEd-7d-5j0">
<objects>
<viewController id="bU7-R8-ocO" customClass="ArtistButtonsViewController" customModule="NeteaseMusic" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="bU7-R8-ocO" customClass="ArtistButtonsViewController" customModule="Netease_Music" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="tOy-S4-hL0">
<rect key="frame" x="0.0" y="0.0" width="276" height="17"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down
Loading

0 comments on commit 756bb7c

Please sign in to comment.