Skip to content

Commit

Permalink
v1.4.2(53)
Browse files Browse the repository at this point in the history
Fix player bug
  • Loading branch information
lithium0003 committed Nov 19, 2019
1 parent b1d657b commit ad8be7d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
8 changes: 4 additions & 4 deletions ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ccViewer/ccViewer.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52;
CURRENT_PROJECT_VERSION = 53;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 7A9X38B4YU;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
Expand All @@ -828,7 +828,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.1;
MARKETING_VERSION = 1.4.2;
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
Expand All @@ -848,7 +848,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ccViewer/ccViewer.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 52;
CURRENT_PROJECT_VERSION = 53;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 7A9X38B4YU;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
Expand All @@ -863,7 +863,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.4.1;
MARKETING_VERSION = 1.4.2;
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
Expand Down
45 changes: 32 additions & 13 deletions ccViewer/ccViewer/CustomPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
var customDelegate = [URL: [CustomAVARLDelegate]]()
var infoItems = [URL: [String: Any]]()
var image: MPMediaItemArtwork?
var playCount = -1

func getURL(storage: String, fileId: String) -> URL {
var allowedCharacterSet = CharacterSet.alphanumerics
Expand Down Expand Up @@ -100,6 +101,9 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
}
return playitem
})
if !self.loop {
playCount = items.count
}
var player = AVQueuePlayer(items: items)
return player
}()
Expand Down Expand Up @@ -181,10 +185,12 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
}

func skipNextTrack() {
let url = (player.currentItem?.asset as? AVURLAsset)?.url
print("skipNextTrack ", playCount)
print(player.items())
let url = prevURL
player.pause()
if player.items().count <= 2 {
if loop {
if loop || UserDefaults.standard.bool(forKey: "keepOpenWhenDone") {
loopSetup()
}
}
Expand Down Expand Up @@ -216,7 +222,15 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
customDelegate.removeValue(forKey: url)
}
}
player.play()
if playCount <= 1 {
playCount = playItems.count
}
else {
player.play()
if playCount > 0 {
playCount -= 1
}
}
}
}

Expand Down Expand Up @@ -275,6 +289,13 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
}

func play(parent: UIViewController) {
do {
try AVAudioSession.sharedInstance().setCategory(.playback)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
}

playerViewController.player = player
playerViewController.updatesNowPlayingInfoCenter = false

Expand Down Expand Up @@ -412,17 +433,14 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
}

func nextTrack() {
let url = prevURL
var reload = UserDefaults.standard.bool(forKey: "keepOpenWhenDone")
if reload && player.items().count > 1 {
reload = false
print("nextTrack ", playCount)
print(player.items())
if playCount > 0 {
playCount -= 1
}
let url = prevURL
if player.items().count <= 2 {
if loop {
reload = false
loopSetup()
}
if reload {
if loop || UserDefaults.standard.bool(forKey: "keepOpenWhenDone") {
loopSetup()
}
}
Expand Down Expand Up @@ -454,8 +472,9 @@ class CustomPlayerView: NSObject, AVPlayerViewControllerDelegate {
}
}
}
if reload {
if playCount == 0 {
player.pause()
playCount = playItems.count
}
}

Expand Down

0 comments on commit ad8be7d

Please sign in to comment.