Process the player information page logic

dev
wenlei 1 year ago
parent 118a3cf6e6
commit 9355fa5d15

@ -48,6 +48,21 @@ class TableViewController: ViewController, UIScrollViewDelegate {
make.edges.equalTo(view)
}
tableView.rx.refresh.subscribe { refreshType in
switch refreshType.element {
case .refresh:
self.headerRefreshTrigger.onNext(())
case .loadMore:
self.footerRefreshTrigger.onNext(())
default: break
}
}.disposed(by: rx.disposeBag)
}
@ -76,20 +91,6 @@ class TableViewController: ViewController, UIScrollViewDelegate {
}).disposed(by: rx.disposeBag)
tableView.rx.refresh.subscribe { refreshType in
switch refreshType.element {
case .refresh:
self.headerRefreshTrigger.onNext(())
case .loadMore:
self.footerRefreshTrigger.onNext(())
default: break
}
}.disposed(by: rx.disposeBag)
isHeaderLoading.bind(to: self.tableView.rx.endRefresh).disposed(by: rx.disposeBag)

@ -12,4 +12,9 @@ extension Notification.Name {
static let notiWecahtResp = Notification.Name("notiWecahtResp")
///
static let notiPlayAudioTrack = Notification.Name("notiPlayAudioTrack")
}

@ -54,7 +54,7 @@ class AudioManager {
var currentTrack: AudioTrack?
var currentTrackIndex: Int {
return playlist?.firstIndex(where: {$0.name == currentTrack?.name}) ?? 0
return playlist?.firstIndex(where: {$0.id == currentTrack?.id}) ?? 0
}
var playlist: [AudioTrack]?
@ -67,7 +67,7 @@ class AudioManager {
}
func playTrack(track: AudioTrack) {
guard let url = URL(string: track.previewUrl ?? "") else {
guard let url = URL(string: track.src ?? "") else {
return
}
@ -84,7 +84,7 @@ class AudioManager {
player?.play()
player?.volume = 1
self.currentTrack = track
NotificationCenter.default.post(name: Notification.Name("song"), object: track)
NotificationCenter.default.post(name: .notiPlayAudioTrack, object: track)

@ -8,33 +8,49 @@
import Foundation
struct AudioTrack: Codable {
var album: Album?
let artists: [Artist]
let availableMarkets: [String]?
let discNumber: Int
let durationMs: Int
let explicit: Bool
let externalUrls: [String: String]
let id: String
let name: String
let previewUrl: String?
let id: String?
let title: String?
let artist: String?
let album: String?
let src: String?
let pic: String?
let lrc: String?
let journalNo: String?
let songNo: Int?
//
// var album: Album?
// let artists: [Artist]
// let availableMarkets: [String]?
// let discNumber: Int
// let durationMs: Int
// let explicit: Bool
// let externalUrls: [String: String]
// let id: String
// let name: String
// let previewUrl: String?
//
var isPlaying: Bool?
enum CodingKeys: String, CodingKey {
case album
case artists
case availableMarkets = "available_markets"
case discNumber = "disc_number"
case durationMs = "duration_ms"
case explicit
case externalUrls = "external_urls"
case id
case name
case previewUrl = "preview_url"
case isPlaying
}
// enum CodingKeys: String, CodingKey {
// case album
// case artists
// case availableMarkets = "available_markets"
// case discNumber = "disc_number"
// case durationMs = "duration_ms"
// case explicit
// case externalUrls = "external_urls"
// case id
// case name
// case previewUrl = "preview_url"
//
// case isPlaying
// }
}
struct TracksResponse: Codable {

@ -173,12 +173,12 @@ class HomeTabBarController: UITabBarController, Navigatable {
playerTabBar.playButton.rx.tap.subscribe { _ in
let audioTrack = AudioTrack.init(album: nil,
artists: [], availableMarkets: nil, discNumber: 1, durationMs: 2, explicit: false, externalUrls: ["1": ""], id: "111", name: "222", previewUrl: "http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3")
// let audioTrack = AudioTrack.init(album: nil,
// artists: [], availableMarkets: nil, discNumber: 1, durationMs: 2, explicit: false, externalUrls: ["1": ""], id: "111", name: "222", previewUrl: "http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3")
AudioManager.sharedInstance.playTrack(track: audioTrack)
// AudioManager.sharedInstance.playTrack(track: audioTrack)
}.disposed(by: rx.disposeBag)
@ -191,7 +191,9 @@ class HomeTabBarController: UITabBarController, Navigatable {
playerTabBar.rx.controlEvent(.touchUpInside).subscribe { _ in
let playerViewModel = PlayerViewModel.init(provider: viewModel.provider)
guard let track = AudioManager.sharedInstance.currentTrack else { return }
let playerViewModel = PlayerViewModel.init(track: track, provider: viewModel.provider)
self.navigator.show(segue: .player(viewModel: playerViewModel), sender: self, transition: .modal)
}.disposed(by: rx.disposeBag)

@ -88,14 +88,22 @@ class HomeViewController: TableViewController {
output.items.bind(to: tableView.rx.items(dataSource: dataSource)).disposed(by: rx.disposeBag)
output.itemSelected.subscribe { [weak self] sectionItem in
switch sectionItem {
default:
let journalDetailViewModel = JournalDetailViewModel.init(provider: viewModel.provider)
output.itemSelected.subscribe { [weak self ]homeSectionItem in
switch homeSectionItem.element {
case .journalDetil(model: let homeJournal):
guard let journalNo = homeJournal.journalNo else { return }
let journalDetailViewModel = JournalDetailViewModel.init(journalNo: journalNo, provider: viewModel.provider)
self?.navigator.show(segue: .journalDetail(viewModel: journalDetailViewModel), sender: self)
default: break
}
}.disposed(by: rx.disposeBag)
isFooterLoading.accept((.loadMore, false))
@ -197,9 +205,10 @@ extension HomeViewController {
let header = HomeSectionView.init()
header.theFMButtonClosures = {[weak self] in
guard let viewModel = self?.viewModel else { return }
let playerViewModel = PlayerViewModel.init(provider: viewModel.provider)
guard let viewModel = self?.viewModel,
let track = AudioManager.sharedInstance.currentTrack else { return }
let playerViewModel = PlayerViewModel.init(track: track, provider: viewModel.provider)
self?.navigator.show(segue: .player(viewModel: playerViewModel), sender: self, transition: .modal)
}

@ -60,8 +60,8 @@ class HomeViewModel: ViewModel, ViewModelType {
input.selection.drive { indexPath in
// guard let sectionItem = self.items.value.first?.items[indexPath.row] else { return }
// self.itemSelected.onNext(sectionItem)
guard let sectionItem = elements.value.first?.items[indexPath.row] else { return }
self.itemSelected.onNext(sectionItem)
}.disposed(by: rx.disposeBag)

@ -69,16 +69,23 @@ class SongViewCell: UITableViewCell {
didSet {
guard let audioTrack = audioTrack else { return }
titleLabel.text = audioTrack.name
titleLabel.text = audioTrack.title
detailLabel.text = "321"
detailLabel.text = (audioTrack.artist ?? "") + "/" + (audioTrack.album ?? "")
coverView.kf.setImage(with: URL.init(string: audioTrack.pic ?? ""))
musicIndicator.state = audioTrack.isPlaying == true ? .playing : .paused
musicIndicator.isHidden = audioTrack.isPlaying == true ? false : true
if AudioManager.sharedInstance.currentTrack?.id == audioTrack.id {
musicIndicator.isHidden = false
musicIndicator.state = AudioManager.sharedInstance.isPlaying() ? .playing : .paused
} else {
musicIndicator.isHidden = true
}
}
}

@ -54,6 +54,7 @@ class JournalDetailController: ViewController, UIScrollViewDelegate {
view.addSubview(commentToolView)
view.addSubview(tableView)
tableView.separatorColor = .clear
tableView.tableHeaderView = headerView
tableView.register(SongViewCell.self, forCellReuseIdentifier: "SongViewCell")
@ -90,11 +91,17 @@ class JournalDetailController: ViewController, UIScrollViewDelegate {
output.itemSelected.subscribe { [weak self] sectionItem in
guard let items = output.items.value.first?.items,
let track = sectionItem.element else { return }
switch sectionItem {
default: break
}
let playerViewModel = PlayerViewModel.init(track: track, provider: viewModel.provider)
self?.navigator.show(segue: .player(viewModel: playerViewModel), sender: self, transition: .modal)
AudioManager.sharedInstance.setPlaylist(list: items)
AudioManager.sharedInstance.playTrack(track: track)
}.disposed(by: rx.disposeBag)
@ -183,7 +190,7 @@ extension JournalDetailController {
return RxTableViewSectionedReloadDataSource<JournalSection>(
configureCell: { dataSource, tableView, indexPath, item in
let cell: SongViewCell = tableView.dequeueReusableCell(withIdentifier: "SongViewCell", for: indexPath) as! SongViewCell
cell.lineView.isHidden = true
cell.audioTrack = item
cell.buttonTapCallback = {audioTrack in

@ -36,12 +36,21 @@ class JournalDetailViewModel: ViewModel, ViewModelType {
}
let itemSelected = PublishSubject<AudioTrack>()
let items = BehaviorRelay<[JournalSection]>.init(value: [])
// let items = BehaviorRelay<[JournalSection]>.init(value: [])
let isExpand = BehaviorRelay<Bool>.init(value: false)
let journalNo: String
init(journalNo: String, provider: IndieMusicAPI) {
self.journalNo = journalNo
super.init(provider: provider)
}
func transform(input: Input) -> Output {
let elements = BehaviorRelay<[JournalSection]>(value: [])
input.viewWillAppear.subscribe { (_) in
@ -56,17 +65,17 @@ class JournalDetailViewModel: ViewModel, ViewModelType {
let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
items.accept([journalSection])
//
// let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
// let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
//
// let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
//
// items.accept([journalSection])
input.selection.drive { indexPath in
guard let sectionItem = self.items.value.first?.items[indexPath.row] else { return }
guard let sectionItem = elements.value.first?.items[indexPath.row] else { return }
self.itemSelected.onNext(sectionItem)
}.disposed(by: rx.disposeBag)
@ -79,7 +88,25 @@ class JournalDetailViewModel: ViewModel, ViewModelType {
let isLick = BehaviorRelay<Bool>.init(value: false)
return Output.init(items: items,
self.requestMusic(journalNo: journalNo).subscribe { audioTrackArray in
let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
let journalSection = JournalSection.init(items: audioTrackArray, journalDetail: journalDetail)
elements.accept([journalSection])
} onError: { error in
}.disposed(by: rx.disposeBag)
return Output.init(items: elements,
selection: input.selection,
itemSelected: itemSelected,
journalDetail: journal,
@ -90,4 +117,13 @@ class JournalDetailViewModel: ViewModel, ViewModelType {
)
}
func requestMusic(journalNo: String) -> Observable<[AudioTrack]> {
return self.provider.journalMusic(journalNo: journalNo)
.trackActivity(loading)
.trackError(error)
}
}

@ -152,10 +152,10 @@ extension MineSingleController {
return RxTableViewSectionedReloadDataSource<MineSingleSection>(
configureCell: { dataSource, tableView, indexPath, item in
let cell: SongViewCell = tableView.dequeueReusableCell(withIdentifier: "SongViewCell", for: indexPath) as! SongViewCell
let it = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
cell.audioTrack = it
// let it = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
//
//
// cell.audioTrack = it
cell.buttonTapCallback = {audioTrack in

@ -41,12 +41,12 @@ class PersonalViewModel: ViewModel, ViewModelType {
func transform(input: Input) -> Output {
let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
tableViewItems.accept([journalSection])
// let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
// let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
//
// let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
//
// tableViewItems.accept([journalSection])

@ -10,7 +10,25 @@ import RxSwift
import RxCocoa
import RxDataSources
class AudioTrackListViewController: TableViewController {
class AudioTrackListViewController: ViewController {
var tableView: UITableView = {
let tableView = UITableView.init()
tableView.register(SongViewCell.self
, forCellReuseIdentifier: "SongViewCell")
tableView.separatorColor = .clear
return tableView
}()
var audioMoreActionBottomView: AudioMoreActionBottomView = {
let audioMoreActionBottomView = AudioMoreActionBottomView.init()
// audioMoreActionBottomView.backgroundColor = .blue
return audioMoreActionBottomView
}()
override func viewDidLoad() {
super.viewDidLoad()
@ -22,19 +40,15 @@ class AudioTrackListViewController: TableViewController {
override func makeUI() {
super.makeUI()
self.tableView.mj_header = nil
self.tableView.mj_footer = nil
view.addSubview(tableView)
view.addSubview(audioMoreActionBottomView)
self.tableView.separatorColor = .clear
let haederView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: BaseDimensions.screenWidth, height: 9))
haederView.backgroundColor = .white
tableView.tableHeaderView = haederView
view.backgroundColor = .white
tableView.register(SongViewCell.self
, forCellReuseIdentifier: "SongViewCell")
}
@ -64,6 +78,8 @@ class AudioTrackListViewController: TableViewController {
}.disposed(by: rx.disposeBag)
self.tableView.mj_header = nil
self.tableView.mj_footer = nil
}
@ -71,6 +87,19 @@ class AudioTrackListViewController: TableViewController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
audioMoreActionBottomView.snp.makeConstraints { make in
make.left.equalTo(view)
make.right.equalTo(view)
make.bottom.equalTo(view)
make.height.equalTo(BaseDimensions.bottomHeight + 48)
}
tableView.snp.makeConstraints { make in
make.left.equalTo(view)
make.right.equalTo(view)
make.top.equalTo(view)
make.bottom.equalTo(audioMoreActionBottomView.snp.top)
}
}
}

@ -33,13 +33,18 @@ class AudioTrackListViewModel: ViewModel, ViewModelType {
let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
let item1 = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "", isPlaying: true)
// let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
//
// let item1 = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "", isPlaying: true)
let journalSection = JournalSection.init(items: [item, item1, item, item], journalDetail: journalDetail)
items.accept([journalSection])
//
// items.accept([journalSection])
if let playlist = AudioManager.sharedInstance.playlist {
let journalSection = JournalSection.init(items: playlist, journalDetail: journalDetail)
items.accept([journalSection])
}

@ -6,6 +6,8 @@
//
import UIKit
import SVProgressHUD
import MarqueeLabel
class PlayerViewTopBar: UIView {
lazy var dropButton: UIButton = {
@ -198,6 +200,23 @@ class PlayerScrollView: UIScrollView {
weak var scrollDelegate: PlayerScrollViewDelegate?
var audioTrack: AudioTrack? {
didSet {
print("audioTrack nil \(audioTrack)")
guard let audioTrack = audioTrack else { return }
playerInfoView.titleLabel.text = audioTrack.title
playerInfoView.artistLabel.text = (audioTrack.artist ?? "") + "/" + (audioTrack.album ?? "")
playerInfoView.coverView.kf.setImage(with: URL.init(string: audioTrack.pic ?? ""))
playerInfoView.numberLabel.text = "VOL \(audioTrack.journalNo ?? "")"
playerInfoView.updateData(audioTrack: audioTrack)
SVProgressHUD.showText(withStatus: audioTrack.title)
print("audioTrack \(audioTrack)")
}
}
override init(frame: CGRect) {
super.init(frame: frame)
@ -461,16 +480,16 @@ class PlayerInfoView: UIView {
}()
var titleLabel: UILabel = {
let titleLabel = UILabel.init()
var titleLabel: MarqueeLabel = {
let titleLabel = MarqueeLabel.init(frame: .zero, rate: 15, fadeLength: 10.0)
titleLabel.font = UIFont.systemFont(ofSize: 20, weight: .medium)
titleLabel.textColor = .init(hex: 0xFFFFFF, alpha: 0.9)
return titleLabel
}()
var artistLabel: UILabel = {
let artistLabel = UILabel.init()
var artistLabel: MarqueeLabel = {
let artistLabel = MarqueeLabel.init(frame: .zero, rate: 15, fadeLength: 10)
artistLabel.font = UIFont.systemFont(ofSize: 12)
artistLabel.textColor = .init(hex: 0xFFFFFF, alpha: 0.6)
@ -489,7 +508,9 @@ class PlayerInfoView: UIView {
var likeButton: UIButton = {
let likeButton = UIButton.init()
likeButton.setImage(UIImage.init(named: "play_like_on"), for: .normal)
likeButton.setImage(UIImage.init(named: "play_like_off"), for: .normal)
likeButton.setImage(UIImage.init(named: "play_like_on"), for: .selected)
likeButton.setContentHuggingPriority(.required, for: .horizontal)
likeButton.setContentCompressionResistancePriority(.required, for: .horizontal)
@ -526,13 +547,13 @@ class PlayerInfoView: UIView {
makeUI()
numberLabel.text = "VOL 1092"
titleLabel.text = "fdsfds"
artistLabel.text = "1233321"
startTimeLabel.text = "00:00"
endTimeLabel.text = "00:00"
coverView.backgroundColor = .gray
// numberLabel.text = "VOL 1092"
// titleLabel.text = "fdsfds"
// artistLabel.text = "1233321"
// startTimeLabel.text = "00:00"
// endTimeLabel.text = "00:00"
//
// coverView.backgroundColor = .gray
}
required init?(coder: NSCoder) {
@ -553,6 +574,16 @@ class PlayerInfoView: UIView {
addSubview(endTimeLabel)
}
func updateData(audioTrack: AudioTrack) {
titleLabel.text = audioTrack.title
artistLabel.text = (audioTrack.artist ?? "") + "/" + (audioTrack.album ?? "")
coverView.kf.setImage(with: URL.init(string: audioTrack.pic ?? ""))
numberLabel.text = "VOL \(audioTrack.journalNo ?? "")"
}
override func layoutSubviews() {
super.layoutSubviews()

@ -53,9 +53,6 @@ class PlayerViewController: ViewController {
UIApplication.shared.beginReceivingRemoteControlEvents()
self.becomeFirstResponder()
// let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handleDismissGesture(_:)))
// view.addGestureRecognizer(panGesture)
// playerControlView.addGestureRecognizer(panGesture)
}
override func viewWillAppear(_ animated: Bool) {
@ -88,8 +85,9 @@ class PlayerViewController: ViewController {
playerScrollView.playerLyricsView.tableView.register(PlayerLyricsCell.self, forCellReuseIdentifier: "PlayerLyricsCell")
guard let viewModel = viewModel as? PlayerViewModel else { return }
guard let viewModel = viewModel as? PlayerViewModel, let audioTrack = viewModel.trackINfo else { return }
playerScrollView.playerInfoView.updateData(audioTrack: audioTrack)
let input = PlayerViewModel.Input.init(viewWillAppear: rx.viewWillAppear,
likeButtonTrigger: playerScrollView.playerInfoView.likeButton.rx.tap.asDriver(),
shareButtonTrigger: playerScrollView.playerInfoView.shareButton.rx.tap.asDriver(),
@ -98,7 +96,8 @@ class PlayerViewController: ViewController {
lastButtonTrigger: playerControlView.lastButton.rx.tap.asDriver(),
nextButtonTrigger: playerControlView.nextButton.rx.tap.asDriver(),
playButtonTrigger: playerControlView.playButton.rx.tap.asDriver(),
moreButtonTrigger: playerViewTopBar.moreButton.rx.tap.asDriver())
moreButtonTrigger: playerViewTopBar.moreButton.rx.tap.asDriver(),
notiPlayAudioTrack: NotificationCenter.default.rx.notification(.notiPlayAudioTrack))
let output = viewModel.transform(input: input)
@ -109,9 +108,7 @@ class PlayerViewController: ViewController {
self.playerViewTopBar.dropButton.rx.tap.subscribe { [weak self] _ in
self?.navigator.dismiss(sender: self)
// self?.navigationController?.dismiss(animated: true)
}.disposed(by: rx.disposeBag)
@ -120,7 +117,7 @@ class PlayerViewController: ViewController {
.disposed(by: rx.disposeBag)
viewModel.isLike.subscribe { [weak self] isLike in
self?.playerScrollView.playerInfoView.likeButton.isSelected = isLike
} .disposed(by: rx.disposeBag)
@ -134,6 +131,13 @@ class PlayerViewController: ViewController {
self?.playerControlView.playButton.isSelected = isPlaying
} .disposed(by: rx.disposeBag)
print("audioTrack222 ")
output.audioTrack.subscribe { [weak self] audioTrack in
print("audioTrack111 \(audioTrack)")
self?.playerScrollView.audioTrack = audioTrack
}.disposed(by: rx.disposeBag)

@ -21,6 +21,7 @@ class PlayerViewModel: ViewModel, ViewModelType {
let nextButtonTrigger: Driver<Void>
let playButtonTrigger: Driver<Void>
let moreButtonTrigger: Driver<Void>
let notiPlayAudioTrack: Observable<Notification>
}
@ -31,8 +32,6 @@ class PlayerViewModel: ViewModel, ViewModelType {
let audioTrack: PublishSubject<AudioTrack>
let toShare: BehaviorRelay<Void>
let toList: BehaviorRelay<Void>
}
let items = BehaviorRelay<[PlayerLyricsSection]>.init(value: [])
@ -45,6 +44,15 @@ class PlayerViewModel: ViewModel, ViewModelType {
let toShare = BehaviorRelay<Void>.init(value: ())
let toList = BehaviorRelay<Void>.init(value: ())
var trackINfo: AudioTrack?
init(track: AudioTrack?, provider: IndieMusicAPI) {
super.init(provider: provider)
guard let track = track else { return }
print("audioTrack333 ")
self.trackINfo = track
self.audioTrack.onNext(track)
}
func transform(input: Input) -> Output {
@ -68,15 +76,20 @@ class PlayerViewModel: ViewModel, ViewModelType {
// totalTracks: <#T##Int#>,
// artists: <#T##[Artist]#>)
let audioTrack = AudioTrack.init(album: nil,
artists: [], availableMarkets: nil, discNumber: 1, durationMs: 2, explicit: false, externalUrls: ["1": ""], id: "111", name: "222", previewUrl: "http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3")
//
// let audioTrack = AudioTrack.init(album: nil,
// artists: [], availableMarkets: nil, discNumber: 1, durationMs: 2, explicit: false, externalUrls: ["1": ""], id: "111", name: "222", previewUrl: "http://downsc.chinaz.net/Files/DownLoad/sound1/201906/11582.mp3")
AudioManager.sharedInstance.setPlaylist(list: [audioTrack])
AudioManager.sharedInstance.playTrack(track: audioTrack)
// AudioManager.sharedInstance.setPlaylist(list: [audioTrack])
// AudioManager.sharedInstance.playTrack(track: audioTrack)
if AudioManager.sharedInstance.isPlaying() {
AudioManager.sharedInstance.pause()
} else {
AudioManager.sharedInstance.resume()
}
}).disposed(by: rx.disposeBag)
@ -99,6 +112,14 @@ class PlayerViewModel: ViewModel, ViewModelType {
}.disposed(by: rx.disposeBag)
input.notiPlayAudioTrack.subscribe { [weak self] noti in
guard let track = noti.element?.object as? AudioTrack else { return }
self?.audioTrack.onNext(track)
}.disposed(by: rx.disposeBag)
return Output.init(items: items,
isLike: isLike,
shuffle: shuffle,

@ -42,13 +42,13 @@ class SearchResultsViewModel: ViewModel, ViewModelType {
let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
tableViewItems.accept([journalSection])
// let journalDetail = JournalDetail.init(audio: "", cover: "", title: "", artist: "", number: "", tags: [], date: 0, content: "", isExpand: false)
// let item = AudioTrack.init(artists: [], availableMarkets: [""], discNumber: 0, durationMs: 0, explicit: false, externalUrls: ["": ""], id: "", name: "123", previewUrl: "")
//
// let journalSection = JournalSection.init(items: [item, item, item, item], journalDetail: journalDetail)
//
// tableViewItems.accept([journalSection])
//
let musicStyleItem = MusicStyle.init(title: "测试", subTitle: "123", backgroundImage: "")

@ -29,4 +29,9 @@ protocol IndieMusicAPI {
///
func journalList(style: String, language: String, pageNum: Int, pageSize: Int) -> Single<[HomeJournal]>
///
func journalMusic(journalNo: String) -> Single<[AudioTrack]>
}

@ -22,6 +22,7 @@ enum APIConfig {
case getUserInfo([String: Any])
case editUserInfo([String: Any])
case journalList([String: Any])
case journalMusic(String)
}
extension APIConfig: TargetType {
@ -43,12 +44,14 @@ extension APIConfig: TargetType {
return "user/my/updateUserInfo"
case .journalList:
return "luoo-music/journal/list"
case .journalMusic(let journalNo):
return "luoo-music/song/getByJournalNo/\(journalNo)"
}
}
var method: Moya.Method {
switch self {
case .wechatAccessToken, .journalList:
case .wechatAccessToken, .journalList, .journalMusic:
return .get
case .sendsms, .login, .autoLogin, .getUserInfo, .editUserInfo:
return .post
@ -57,7 +60,7 @@ extension APIConfig: TargetType {
var parameterEncoding: ParameterEncoding {
switch self {
case .wechatAccessToken, .journalList:
case .wechatAccessToken, .journalList, .journalMusic:
return URLEncoding.default
case .login:
return JSONEncoding.default
@ -71,7 +74,7 @@ extension APIConfig: TargetType {
var task: Task {
var parameters: [String: Any] = [:]
switch self {
case .wechatAccessToken, .journalList:
case .wechatAccessToken, .journalList, .journalMusic:
return .requestPlain
case .login(_, _, let dic), .sendsms(_, let dic), .autoLogin(let dic), .getUserInfo(let dic), .editUserInfo(let dic):
@ -96,7 +99,7 @@ extension APIConfig: TargetType {
var headers : [String : String]? {
switch self {
case .autoLogin, .getUserInfo, .journalList:
case .autoLogin, .getUserInfo, .journalList, .journalMusic:
return ["token": AuthManager.shared.token?.basicToken ?? ""]
default:
return nil

@ -121,4 +121,10 @@ extension RestApi {
}
func journalMusic(journalNo: String) -> Single<[AudioTrack]> {
return requestObject(.journalMusic(journalNo), with: "data", type: [AudioTrack].self)
}
}

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "play_like_off.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M19.612 5.38797C19.1722 4.94794 18.65 4.59888 18.0752 4.36073C17.5005 4.12258 16.8844 4 16.2623 4C15.6401 4 15.0241 4.12258 14.4493 4.36073C13.8746 4.59888 13.3524 4.94794 12.9126 5.38797L11.9998 6.30075L11.087 5.38797C10.1986 4.49956 8.99364 4.00046 7.73725 4.00046C6.48085 4.00046 5.27591 4.49956 4.38751 5.38797C3.4991 6.27637 3 7.48131 3 8.73771C3 9.9941 3.4991 11.199 4.38751 12.0874L5.30029 13.0002L11.9998 19.6997L18.6992 13.0002L19.612 12.0874C20.0521 11.6476 20.4011 11.1254 20.6393 10.5507C20.8774 9.9759 21 9.35985 21 8.73771C21 8.11556 20.8774 7.49951 20.6393 6.92475C20.4011 6.34999 20.0521 5.82779 19.612 5.38797V5.38797Z" stroke="white" stroke-opacity="0.7" style="stroke:white;stroke-opacity:0.7;" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 894 B

@ -25,6 +25,7 @@ target 'IndieMusic' do
pod 'ESTMusicIndicator'
pod 'IQKeyboardManagerSwift'
pod 'lottie-ios'
pod 'MarqueeLabel'
pod 'NSObject+Rx'

Loading…
Cancel
Save