nroi / paracusia

Elixir library for MPD (Music Player Daemon)
MIT License
12 stars 2 forks source link

Failure to start when MPD is stopped #8

Closed nroi closed 6 years ago

nroi commented 6 years ago

Since MPD version 0.21, paracusia fails to start when MPD is stopped:

12:01:31.658 [info]  Application paracusia exited: Paracusia.start(:normal, []) returned an error: shutdown: failed to start child: Paracusia.PlayerState
    ** (EXIT) an exception was raised:
        ** (ArgumentError) argument error
            :erlang.binary_to_integer(nil)
            (paracusia) lib/paracusia/mpd_client/status.ex:45: Paracusia.MpdClient.Status.status/0
            (paracusia) lib/paracusia/player_state.ex:76: Paracusia.PlayerState.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application paracusia: Paracusia.start(:normal, []) returned an error: shutdown: failed to start child: Paracusia.PlayerState
    ** (EXIT) an exception was raised:
        ** (ArgumentError) argument error
            :erlang.binary_to_integer(nil)
            (paracusia) lib/paracusia/mpd_client/status.ex:45: Paracusia.MpdClient.Status.status/0
            (paracusia) lib/paracusia/player_state.ex:76: Paracusia.PlayerState.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

This is because MPD does not send a line starting with volume:. According to MPDs documentation, MPD should send -1 as volume when the volume cannot be determined, and until version 0.21, this is what happened when MPD was stopped.