text: // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
  
  import * as Curry from "bs-platform/lib/es6/curry.js";
  import * as React from "react";
  import * as Caml_array from "bs-platform/lib/es6/caml_array.js";
  import * as Caml_int32 from "bs-platform/lib/es6/caml_int32.js";
  import * as MusicPlayer$ReasonMusicPlayer from "./MusicPlayer.bs.js";
  
  function useMusicPlayer(param) {
    var match = React.useContext(MusicPlayer$ReasonMusicPlayer.musicPlayerContext);
    var dispatch = match[1];
    var state = match[0];
    var playing = state.playing;
    var trackList = state.tracks;
    var currentTrackName = playing ? Caml_array.caml_array_get(state.tracks, playing._0).name : "Please choose a track to play";
    var pauseTrack = function (param) {
      return Curry._1(dispatch, /* PauseTrack */0);
    };
    var playTrack = function (index) {
      if (playing) {
        if (index === playing._0) {
          return Curry._1(dispatch, /* PauseTrack */0);
        } else {
          state.audioPlayer.pause();
          return Curry._1(dispatch, /* PlayTrack */{
                      _0: index
                    });
        }
      } else {
        return Curry._1(dispatch, /* PlayTrack */{
                    _0: index
                  });
      }
    };
    var trackListLength = trackList.length;
    var playPreviousTrack = function (param) {
      if (playing) {
        return playTrack(Caml_int32.mod_(Caml_int32.mod_(playing._0 - 1 | 0, trackListLength) + trackListLength | 0, trackListLength));
      }
      
    };
    var playNextTrack = function (param) {
      if (playing) {
        return playTrack(Caml_int32.mod_(playing._0 + 1 | 0, trackListLength));
      }
      
    };
    return [
            playing,
            trackList,
            currentTrackName,
            pauseTrack,
            playTrack,
            playPreviousTrack,
            playNextTrack
          ];
  }
  
  export {
    useMusicPlayer ,
    
  }
  /* react Not a pure module */
  