Closed zluo01 closed 2 years ago
There is no sample code available. Before using this package, you should get acquainted with RxSwift, which can be a steep learning curve. Once you get the hang of it things become quite self-explanatory.
Hi, Just want to make sure I use ur package properly.
I have a remote mpd server with version 0.20. And I try to connect to the server which has ip address 192.168.0.220
in my local network and on default port 6600, by creating Mpd instance with following
let connectionProperties = [ConnectionProperties.name.rawValue: "",
ConnectionProperties.host.rawValue: "192.168.0.220",
ConnectionProperties.port.rawValue: 6600,
ConnectionProperties.password.rawValue: ""] as [String: Any]
print(connectionProperties)
print(UserDefaults.standard)
mpdPlayer = MPDPlayer.init(connectionProperties: connectionProperties, userDefaults: UserDefaults.standard)
Then, I try to browse files in directory _db/albums
with following
let folder = Folder.init(id: "albumDB", source: .Local, path: "_db/albums", name: "albums");
print(mpdPlayer.version)
let browseViewModel = mpdPlayer.browse.folderContentsBrowseViewModel(folder)
browseViewModel.load()
let folderContentsResult = browseViewModel.folderContentsObservable
let disposeBag = DisposeBag()
folderContentsResult.subscribe(onNext: { content in
print(2,content)
completion(.success(AlbumList(albums: [])))
})
.disposed(by: disposeBag)
I try to copy the code u have in MPDBrowseTests for browsing folders, but on my end, it shows there is no toBlocking methods. Wonder if u have specific version or RxSwift ? At the mean time, the print out is empty string when I try to print out the mpd version, does it mean my connection is not successful ?
Thank you very much.
The version of RxSwift that is used is determined by Swift Package Manager, based on the content of Package.swift of MPDConnector, so that should work. I've never seen any message about toBlocking that was missing.
If the version that is printed out is empty because you're not adding the player via MPDPlayerBrowser. That will take care of connecting to the player and getting the version number. You can add a manual player through persistPlayer.
@zluo01 would you mind sharing some code yourself, now that you have some experience ?
I would also be interested in sample code or documentation, so if you could share some code that would be highly appreciated. Thanks !
No, I cannot make it work on my end. Feel free to try it out and share your way of working example here.
Hi, I try to use your package in my project, I am a beginner for swift so I am not sure how to start with this package. (i.e. how to create client to connect to mpd or use the protocol mentioned in the ReadMe). Would u mind sharing some code example on how to do that?
Thank you very much.