Streaming remote audio on iOS with HysteriaPlayer Tutorial (2)

In this part of tutorial, I am going build a simple player interface with HysteriaPlayer.

The simple interface with those basic views and elements.

  • Play, Pause, Next, Previous function
  • Repeat, Shuffle function
  • Playing item's current and duration time
  • Slider that seeks to time in HysteriaPlayer
  • Artwork with SpinningDiskView

Catalog

In part 0, what we want? why HysteriaPlayer?

In part 1, demonstrating how to play remote audios with HysteriaPlayer.

In part 2, making a simple player user interface.

In part 3, registering lock screen details and remote controls.

You can download source code here with branch tutorial-2.


I created a new PlayerViewController class extends UIViewController and dragged some views on xib. Assuming everyone is familiar with that. We skip this process.

We have to implement HysteriaPlayerDelegate protocol in PlayerViewController. HysteriaPlayerDelegate protocol have four optional methods that releated to interface updating. Docs

  • - (void)hysteriaPlayerCurrentItemChanged:(AVPlayerItem *)item;
  • - (void)hysteriaPlayerRateChanged:(BOOL)isPlaying;
  • - (void)hysteriaPlayerDidReachEnd;
  • - (void)hysteriaPlayerCurrentItemPreloaded:(CMTime)time;

Back to PlayerViewController.m, we have to add and remove delegate with addDelegate: and removeDelegate: mothods when PlayerViewController didAppear and didDisappear.

Note that HysteriaPlayer not using HysteriaPlayer.delegate but add/remove delegates because it allows multiple delegates at the same time.

Implementing two HysteriaPlayerDelegate protocol methods: hysteriaPlayerCurrentItemChanged: and hysteriaPlayerRateChanged:

I used SpinningDiskView to display artwork.

seetToTime, current/duration time, next, previous...

not finished.