Skip to content

Latest commit

 

History

History
111 lines (66 loc) · 3.23 KB

REQUIREMENTS.md

File metadata and controls

111 lines (66 loc) · 3.23 KB

Requirements

  1. ✅ The app should allow users to search for songs, albums or artists by typing in search criteria.

  2. ✅ The app should display the search results in a list showing the song name, artist, and album art.

  3. ✅ The app should support paging the search results by providing the ability to load more records. Each page limits 20 records.

  4. ✅ The app should allow users to filter the search results by country or media type.

  5. ✅ The app should provide the ability to bookmark songs by adding them to a "favorites" list, which can be accessed later.

  6. ✅ The app should be available in English, Traditional Chinese (Hong Kong), and Simplified Chinese (China) languages.

  7. ✅ The app should have a clean and intuitive design that is easy to use.

  8. ✅ The app should support iOS 12+ / Android 6.0+.

Solutions

Pagination
  1. Set a limit to get the track from API.

  2. Create an array to store new tracks which get from API.

  3. When user scroll to the last cell from the track table, it will call the API again and append new tracks to store in the array.

  4. If the new API return the array is below the limit, it WILL NOT call the API when user scroll to the last cell. It prevents to call the API continuously.

Localizable
  1. Go to the project page and Info tab.

  2. Add the language which you needed in Localization. As the project requirement, I added English, Chinese (Hong Kong) and Chinese, Simplified (China).

  3. Create a string file called Localizable.string.

  4. Go to the Inspector which in Xcode's right hand side. Tick all the language which you needed. The string file will create the sub-file for each language.

  5. Add below code to apply the localizable for each text.

    NSLocalizedString(key, comment: "")
  6. Done 🍻.

Play music
  1. Implement AVFoundation to play the music track.

    import AVFoundation
  2. Add PeriodicTimeObserver to observe music's duration time and current time.

    self.player.addPeriodicTimeObserver()
  3. Insert the track AVPlayerItem in to the player.

    self.player.insert(AVPlayerItem(url: URL(string: previewUrl)!), after: nil)
  4. Play the music.

    self.player.play()
  5. Done 🍻.

Use model presentation
  1. Apply model presentation method to show the player.

  2. In modal presentation, there cannot tigger the viewWillAppear and viewDidAppear function by callback. Therefore, I added observer to observe the dismiss action.

    vcPlay.vm.psDismiss.subscribe(onNext: {
        self.refreshFavourite()
    }).disposed(by: self.vm.disposeBag)
  3. When user clicked Favourite button in the player, the track will add into Favourite. User can browse the track which can be accessed later on the top of home page.

  4. Done 🍻.

Future features

  1. Unit test & UI test

  2. Favourite function store to local devide

  3. Play previous & next for player

  4. Others