From af8b96c2feeb4519985d12e68e68054a6726e335 Mon Sep 17 00:00:00 2001 From: yoheimuta Date: Wed, 6 Oct 2021 19:28:31 +0900 Subject: [PATCH 1/3] chore: Remove an invalid framework --- RxMusicPlayer.xcodeproj/project.pbxproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/RxMusicPlayer.xcodeproj/project.pbxproj b/RxMusicPlayer.xcodeproj/project.pbxproj index 3132fa9..ca9db45 100644 --- a/RxMusicPlayer.xcodeproj/project.pbxproj +++ b/RxMusicPlayer.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 26BC08410487D678000C1FD8 /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B9F36DF15A393FC092613E9 /* Pods_Example.framework */; }; C23F042D262C40D4004686CE /* RxSwift.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A64DB9262C3EB40018641C /* RxSwift.xcframework */; }; C23F042E262C40D4004686CE /* RxSwift.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C2A64DB9262C3EB40018641C /* RxSwift.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C23F043B262C4183004686CE /* RxSwift.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C2A64DB9262C3EB40018641C /* RxSwift.xcframework */; }; @@ -245,7 +244,6 @@ C23F0446262C4228004686CE /* RxCocoa.xcframework in Frameworks */, C23F0452262C428F004686CE /* RxRelay.xcframework in Frameworks */, FF11FBF92329E50E0043C29B /* RxMusicPlayer.framework in Frameworks */, - 26BC08410487D678000C1FD8 /* Pods_Example.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; From fb461541ec018dc4cea9257b7854eb310329f1e3 Mon Sep 17 00:00:00 2001 From: yoheimuta Date: Wed, 6 Oct 2021 19:29:05 +0900 Subject: [PATCH 2/3] feat: Introduce a new skipDownloading parameter --- RxMusicPlayer/RxMusicPlayerItem.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RxMusicPlayer/RxMusicPlayerItem.swift b/RxMusicPlayer/RxMusicPlayerItem.swift index 4d761e0..a12aa57 100644 --- a/RxMusicPlayer/RxMusicPlayerItem.swift +++ b/RxMusicPlayer/RxMusicPlayerItem.swift @@ -27,14 +27,16 @@ open class RxMusicPlayerItem: NSObject { /** Initialize Metadata with a prefetched one. - If one of the arguments is not nil, the player will skip downloading the metadata. + If skipDownloading is true, the player will use the given parameters, instead of downloading the metadata. + Otherwise, the player will download the metadata, and then use the given parameters as default values. */ public init(duration: CMTime? = nil, lyrics: String? = nil, title: String? = nil, album: String? = nil, artist: String? = nil, - artwork: UIImage? = nil) { + artwork: UIImage? = nil, + skipDownloading: Bool = false) { self.duration = duration self.lyrics = lyrics self.title = title @@ -42,8 +44,7 @@ open class RxMusicPlayerItem: NSObject { self.artist = artist self.artwork = artwork - if duration != nil || lyrics != nil || title != nil || - album != nil || artist != nil || artist != nil { + if skipDownloading { didAllSetRelay.accept(true) } } From 00ef3c16a12fabe1c47f0c7a3e843600d92d8eea Mon Sep 17 00:00:00 2001 From: yoheimuta Date: Wed, 6 Oct 2021 19:33:44 +0900 Subject: [PATCH 3/3] example: Test to work setting default metadata --- Example/TableViewController.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Example/TableViewController.swift b/Example/TableViewController.swift index 3f510b8..18bcb04 100644 --- a/Example/TableViewController.swift +++ b/Example/TableViewController.swift @@ -5,6 +5,7 @@ // Created by YOSHIMUTA YOHEI on 2019/09/12. // Copyright © 2019 YOSHIMUTA YOHEI. All rights reserved. // +// swiftlint:disable line_length import RxCocoa import RxMusicPlayer @@ -35,15 +36,24 @@ class TableViewController: UITableViewController { super.viewDidLoad() // 1) Create a player - let items = [ + var items = [ "https://storage.googleapis.com/great-dev/oss/musicplayer/tagmp3_1473200_1.mp3", "https://storage.googleapis.com/great-dev/oss/musicplayer/tagmp3_2160166.mp3", "https://storage.googleapis.com/great-dev/oss/musicplayer/tagmp3_4690995.mp3", "https://storage.googleapis.com/great-dev/oss/musicplayer/tagmp3_9179181.mp3", - "https://storage.googleapis.com/great-dev/oss/musicplayer/bensound-extremeaction.mp3", - "https://storage.googleapis.com/great-dev/oss/musicplayer/bensound-littleplanet.mp3", ] .map({ RxMusicPlayerItem(url: URL(string: $0)!) }) + // The default metadata is ignored since this item's original metadata are set already. + items.append(RxMusicPlayerItem(url: URL(string: "https://storage.googleapis.com/great-dev/oss/musicplayer/bensound-extremeaction.mp3")!, + meta: RxMusicPlayerItem.Meta(title: "defaultTitle", + album: "defaultAlbum", + artist: "defaultArtist", + skipDownloading: false))) + // The default metadata is used since this item's original metadata are empty. + items.append(RxMusicPlayerItem(url: URL(string: "https://storage.googleapis.com/great-dev/oss/musicplayer/bensound-littleplanet.mp3")!, + meta: RxMusicPlayerItem.Meta(title: "defaultTitle", + album: "defaultAlbum", + artist: "defaultArtist"))) let player = RxMusicPlayer(items: Array(items[0 ..< 4]))! // 2) Control views