diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88f9974 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_build/* diff --git a/docs/Mpd/.dune-keep b/.ocamlformat similarity index 100% rename from docs/Mpd/.dune-keep rename to .ocamlformat diff --git a/Makefile b/Makefile index 52bf522..59ce3a0 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ documentation : dune build @doc find _build/default/_doc/_html/libmpdclient/ -type f |xargs sed -i 's/\.\.\/odoc\.css/odoc\.css/g' - mv _build/default/_doc/_html/odoc.css _build/default/_doc/_html/libmpdclient/ + mv _build/default/_doc/_html/odoc.support/odoc.css _build/default/_doc/_html/libmpdclient/ rm -rf docs/* cp -rf _build/default/_doc/_html/libmpdclient/* docs/ dune clean diff --git a/bin/Ompdc_common.ml b/bin/Ompdc_common.ml index bfbc9da..2ce6162 100644 --- a/bin/Ompdc_common.ml +++ b/bin/Ompdc_common.ml @@ -22,44 +22,55 @@ open Mpd.Protocol let version = "not.yet" let sdocs = Manpage.s_common_options let docs = Manpage.s_common_options -let exits = Term.default_exits +let exits = Cmd.Exit.defaults -let help _copts man_format cmds topic = match topic with -| None -> `Help (`Pager, None) (* help about the program. *) -| Some topic -> - let topics = "topics" :: "patterns" :: "environment" :: cmds in - let conv, _ = Cmdliner.Arg.enum (List.rev_map (fun s -> (s, s)) topics) in - match conv topic with - | `Error e -> `Error (false, e) - | `Ok t when t = "topics" -> List.iter print_endline topics; `Ok () - | `Ok t when List.mem t cmds -> `Help (man_format, Some t) - | `Ok _ -> - let page = (topic, 7, "", "", ""), [`S topic; `P "Say something";] in - `Ok (Cmdliner.Manpage.print man_format Format.std_formatter page) +let help _copts man_format cmds topic = + match topic with + | None -> `Help (`Pager, None) (* help about the program. *) + | Some topic -> ( + let topics = "topics" :: "patterns" :: "environment" :: cmds in + let conv, _ = Cmdliner.Arg.enum (List.rev_map (fun s -> (s, s)) topics) in + match conv topic with + | `Error e -> `Error (false, e) + | `Ok t when t = "topics" -> + List.iter print_endline topics; + `Ok () + | `Ok t when List.mem t cmds -> `Help (man_format, Some t) + | `Ok _ -> + let page = + ((topic, 7, "", "", ""), [ `S topic; `P "Say something" ]) + in + `Ok (Cmdliner.Manpage.print man_format Format.std_formatter page)) -let help_section = [ - `S Manpage.s_common_options; - `P "These options are common to all commands."; - `S Manpage.s_bugs; `P "Check bug reports at https://github.com/cedlemo/OCaml-libmpdclient/issues"; - `S Manpage.s_authors; `P "Cedric Le Moigne " - ] +let help_section = + [ + `S Manpage.s_common_options; + `P "These options are common to all commands."; + `S Manpage.s_bugs; + `P + "Check bug reports at \ + https://github.com/cedlemo/OCaml-libmpdclient/issues"; + `S Manpage.s_authors; + `P "Cedric Le Moigne "; + ] (* Options common to all commands *) -type mpd_opts = {host : string; port : int} +type mpd_opts = { host : string; port : int } -let common_opts host port = - {host; port} +let common_opts host port = { host; port } let common_opts_t = let host = let doc = "Set the address of the Mpd server." in - let env = Arg.env_var "OMPDC_HOST" ~doc in - Arg.(value & opt string "127.0.0.1" & info ["h"; "host"] ~docs ~env ~docv:"HOST") + let env = Cmd.Env.info "OMPDC_HOST" ~doc in + Arg.( + value & opt string "127.0.0.1" + & info [ "h"; "host" ] ~docs ~env ~docv:"HOST") in let port = let doc = "Set the port of the Mpd server." in - let env = Arg.env_var "OMPDC_PORT" ~doc in - Arg.(value & opt int 6600 & info ["p"; "port"] ~docs ~env ~docv:"PORT") + let env = Cmd.Env.info "OMPDC_PORT" ~doc in + Arg.(value & opt int 6600 & info [ "p"; "port" ] ~docs ~env ~docv:"PORT") in Term.(const common_opts $ host $ port) @@ -70,34 +81,35 @@ let help_cmd = in let doc = "display help about ompdc and ompdc commands" in let man = - [`S Manpage.s_description; - `P "Prints help about ompdc commands and other subjects..."; - `Blocks help_section; ] + [ + `S Manpage.s_description; + `P "Prints help about ompdc commands and other subjects..."; + `Blocks help_section; + ] in - Term.(ret - (const help $ common_opts_t $ Arg.man_format $ Term.choice_names $topic)), - Term.info "help" ~doc ~exits ~man + ( Term.( + ret + (const help $ common_opts_t $ Arg.man_format $ Term.choice_names $ topic)), + Cmd.info "help" ~doc ~exits ~man ) - -let initialize_client {host; port} = - let connection = Mpd.Connection.initialize host port in - let client = Mpd.Client.initialize connection in - let _ = print_endline ("Mpd server : " ^ (Mpd.Client.mpd_banner client)) in - client +let initialize_client { host; port } = + let connection = Mpd.Connection.initialize host port in + let client = Mpd.Client.initialize connection in + let _ = print_endline ("Mpd server : " ^ Mpd.Client.mpd_banner client) in + client let check_for_mpd_error mpd_response = - let response = ( + let response = match mpd_response with | Ok msg -> ( - match msg with - | None -> "" - | Some str -> "Mpd response: " ^ str - ) + match msg with None -> "" | Some str -> "Mpd response: " ^ str) | Error (ack_error, _ack_cmd_num, _ack_cmd, ack_message) -> - String.concat " " ["Error type:"; - Mpd.Protocol.error_name ack_error; - "-- error message:"; - ack_message] - ) + String.concat " " + [ + "Error type:"; + Mpd.Protocol.error_name ack_error; + "-- error message:"; + ack_message; + ] in print_endline response diff --git a/bin/Ompdc_idle.ml b/bin/Ompdc_idle.ml index c7fa90b..5edba7a 100644 --- a/bin/Ompdc_idle.ml +++ b/bin/Ompdc_idle.ml @@ -19,7 +19,6 @@ open Lwt.Infix open Notty open Ompdc_common - module Terminal = Notty_lwt.Term type status = { @@ -31,30 +30,29 @@ type status = { } let fetch_status client = - Mpd.Client_lwt.status client - >>= fun response -> - match response with - | Error message -> Lwt.return (Error message) - | Ok s -> - let timestamp = Unix.time () in - let state = Mpd.Status.state s in - let volume = Mpd.Status.volume s in - let song = Mpd.Status.song s in - Mpd.Queue_lwt.playlist client - >>= fun queue -> - Lwt.return (Ok {timestamp; state; volume; queue; song}) + Mpd.Client_lwt.status client >>= fun response -> + match response with + | Error message -> Lwt.return (Error message) + | Ok s -> + let timestamp = Unix.time () in + let state = Mpd.Status.state s in + let volume = Mpd.Status.volume s in + let song = Mpd.Status.song s in + Mpd.Queue_lwt.playlist client >>= fun queue -> + Lwt.return (Ok { timestamp; state; volume; queue; song }) let update_status status client = match status with | Error _ -> Lwt.return status - | Ok s -> Mpd.Client_lwt.noidle client - >>= fun _ -> - let now = Unix.time () in - if ((now -. s.timestamp) > 4.0) then fetch_status client - else Lwt.return status + | Ok s -> + Mpd.Client_lwt.noidle client >>= fun _ -> + let now = Unix.time () in + if now -. s.timestamp > 4.0 then fetch_status client + else Lwt.return status let gen_state_img status = - let state_img = match status.state with + let state_img = + match status.state with | Mpd.Status.Play -> I.(string A.(fg green) "play") | Mpd.Status.Pause -> I.(string A.(fg lightblack) "Pause") | Mpd.Status.Stop -> I.(string A.(fg black ++ bg lightblack) "Stop") @@ -63,111 +61,109 @@ let gen_state_img status = I.(string A.(fg white) "[state ] : " <|> state_img) let gen_volume_img status = - I.(strf ~attr:A.(fg white) "[volume] : %d" status.volume) + I.(strf ~attr:A.(fg white) "[volume] : %d" status.volume) let gen_playlist_img status (w, _h) = match status.queue with - | PlaylistError message -> Lwt.return I.(strf ~attr:A.(fg red) "Error: %s" message) + | PlaylistError message -> + Lwt.return I.(strf ~attr:A.(fg red) "Error: %s" message) | Playlist songs -> - let gen_song_img i song = - let title = Mpd.Song.title song in - let artist = Mpd.Song.artist song in - if status.song = i then - I.(strf ~attr:A.(fg lightred ++ bg lightblack) "+ %s : %s" title artist) - else - I.(strf ~attr:A.(fg lightblack) "- %s : %s" title artist) - in - let song_imgs = List.mapi gen_song_img songs in - let lines = List.map (fun i -> - let left_margin = 4 in - let i_w = I.width i in - let remain = let r = w - (i_w + left_margin) in (max r 0) in - I.hpad left_margin remain i) - song_imgs in - Lwt.return I.(vcat lines) + let gen_song_img i song = + let title = Mpd.Song.title song in + let artist = Mpd.Song.artist song in + if status.song = i then + I.( + strf ~attr:A.(fg lightred ++ bg lightblack) "+ %s : %s" title artist) + else I.(strf ~attr:A.(fg lightblack) "- %s : %s" title artist) + in + let song_imgs = List.mapi gen_song_img songs in + let lines = + List.map + (fun i -> + let left_margin = 4 in + let i_w = I.width i in + let remain = + let r = w - (i_w + left_margin) in + max r 0 + in + I.hpad left_margin remain i) + song_imgs + in + Lwt.return I.(vcat lines) let render status (w, h) = - match status with - | Error message -> Lwt.return I.(strf ~attr:A.(fg red) "[there is a pb %s]" message) - | Ok status -> let state_img = gen_state_img status in + match status with + | Error message -> + Lwt.return I.(strf ~attr:A.(fg red) "[there is a pb %s]" message) + | Ok status -> + let state_img = gen_state_img status in let volume_img = gen_volume_img status in - gen_playlist_img status (w, h) - >>= fun songs_img -> + gen_playlist_img status (w, h) >>= fun songs_img -> Lwt.return I.(state_img <-> volume_img <-> songs_img) let listen_mpd_event client = Mpd.Client_lwt.idle client >|= fun evt -> `Mpd_event evt -let event term = Lwt_stream.get (Terminal.events term) >|= function - | Some (`Resize _ | #Unescape.event as x) -> x +let event term = + Lwt_stream.get (Terminal.events term) >|= function + | Some ((`Resize _ | #Unescape.event) as x) -> x | None -> `End let rec loop term (e, t) dim client status = - (e t) >>= function - | `End | `Key (`Escape, []) | `Key (`ASCII 'C', [`Ctrl]) -> + e t >>= function + | `End | `Key (`Escape, []) | `Key (`ASCII 'C', [ `Ctrl ]) -> Mpd.Client_lwt.close client | `Mpd_event _event_name -> - fetch_status client - >>= fun status' -> - render status' dim - >>= fun img -> - Terminal.image term img - >>= fun () -> - loop term (e, listen_mpd_event client) dim client status' + fetch_status client >>= fun status' -> + render status' dim >>= fun img -> + Terminal.image term img >>= fun () -> + loop term (e, listen_mpd_event client) dim client status' | `Resize dim -> - update_status status client - >>= fun status' -> - render status' dim - >>= fun img -> - Terminal.image term img - >>= fun () -> - loop term (event term, t) dim client status' + update_status status client >>= fun status' -> + render status' dim >>= fun img -> + Terminal.image term img >>= fun () -> + loop term (event term, t) dim client status' | _ -> - update_status status client - >>= fun status' -> - render status' dim - >>= fun img -> - Terminal.image term img - >>= fun () -> - loop term (event term, t) dim client status' + update_status status client >>= fun status' -> + render status' dim >>= fun img -> + Terminal.image term img >>= fun () -> + loop term (event term, t) dim client status' let interface client = let term = Terminal.create () in let size = Terminal.size term in - fetch_status client - >>= fun result_status -> - render result_status size - >>= fun img -> - Terminal.image term img - >>= fun () -> - loop term (event term, listen_mpd_event client) size client result_status + fetch_status client >>= fun result_status -> + render result_status size >>= fun img -> + Terminal.image term img >>= fun () -> + loop term (event term, listen_mpd_event client) size client result_status let idle common_opts = let open Mpd in - let {host; port} = common_opts in + let { host; port } = common_opts in let main_thread = - Connection_lwt.initialize host port - >>= fun connection -> - Client_lwt.initialize connection - >>= fun client -> - interface client + Connection_lwt.initialize host port >>= fun connection -> + Client_lwt.initialize connection >>= fun client -> interface client in - Lwt_main.run ( - Lwt.catch - (fun () -> main_thread) - (function - | Mpd.Connection_lwt.Lwt_unix_exn message -> - Lwt_io.write_line Lwt_io.stderr message - | _ -> Lwt_io.write_line Lwt_io.stderr "Exception not handled. Exit ..." - ) - ) + Lwt_main.run + (Lwt.catch + (fun () -> main_thread) + (function + | Mpd.Connection_lwt.Lwt_unix_exn message -> + Lwt_io.write_line Lwt_io.stderr message + | _ -> + Lwt_io.write_line Lwt_io.stderr "Exception not handled. Exit ...")) open Cmdliner + let cmd = - let doc = "Use Ompdc as an Mpd server events listener. Quit with Ctl+Alt+C." in - let man = [ `S Manpage.s_description; - `P "Idle command that display events of the Mpd server."; - `Blocks help_section - ] in - Term.(const idle $ common_opts_t), - Term.info "idle" ~doc ~sdocs ~exits ~man + let doc = + "Use Ompdc as an Mpd server events listener. Quit with Ctl+Alt+C." + in + let man = + [ + `S Manpage.s_description; + `P "Idle command that display events of the Mpd server."; + `Blocks help_section; + ] + in + (Term.(const idle $ common_opts_t), Cmd.info "idle" ~doc ~sdocs ~exits ~man) diff --git a/bin/Ompdc_playback.ml b/bin/Ompdc_playback.ml index e801bfb..bc4a9a5 100644 --- a/bin/Ompdc_playback.ml +++ b/bin/Ompdc_playback.ml @@ -20,19 +20,22 @@ open Cmdliner open Ompdc_common let play common_opts song_pos = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.play client song_pos in Mpd.Client.close client let play_id common_opts song_id = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.playid client song_id in Mpd.Client.close client let song_pos = - let doc = "Integer value that represents the position of a song in the current playlist." in + let doc = + "Integer value that represents the position of a song in the current \ + playlist." + in Arg.(value & pos 0 int 0 & info [] ~doc ~docv:"SONG_POS") let song_id = @@ -40,135 +43,97 @@ let song_id = Arg.(value & pos 0 int 0 & info [] ~doc ~docv:"SONG_ID") let play_t = - let doc = "Play the song at SONG_POS in the playlist" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const play $ common_opts_t $ song_pos), - Term.info "play" ~doc ~sdocs ~exits ~man + let doc = "Play the song at SONG_POS in the playlist" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const play $ common_opts_t $ song_pos), + Cmd.info "play" ~doc ~sdocs ~exits ~man ) let play_id_t = - let doc = "Play the song SONG_ID." - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const play $ common_opts_t $ song_id), - Term.info "play_id" ~doc ~sdocs ~exits ~man + let doc = "Play the song SONG_ID." in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const play $ common_opts_t $ song_id), + Cmd.info "play_id" ~doc ~sdocs ~exits ~man ) let time = - let doc = "Float value that could represents the length of a song or the \ - starting point to play" in + let doc = + "Float value that could represents the length of a song or the starting \ + point to play" + in Arg.(value & pos 1 float 0.0 & info [] ~doc ~docv:"TIME") let seek common_opts song_pos time = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.seek client song_pos time in Mpd.Client.close client let seek_id common_opts song_id time = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.seekid client song_id time in Mpd.Client.close client let seek_cur common_opts time = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.seekcur client time in Mpd.Client.close client let seek_t = - let doc = "Play the song at SONG_POS in the playlist at TIME" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const seek $ common_opts_t $ song_pos $ time), - Term.info "seek" ~doc ~sdocs ~exits ~man + let doc = "Play the song at SONG_POS in the playlist at TIME" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const seek $ common_opts_t $ song_pos $ time), + Cmd.info "seek" ~doc ~sdocs ~exits ~man ) let seek_id_t = - let doc = "Play the song SONG_ID at TIME" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const seek_id $ common_opts_t $ song_id $ time), - Term.info "seek_id" ~doc ~sdocs ~exits ~man + let doc = "Play the song SONG_ID at TIME" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const seek_id $ common_opts_t $ song_id $ time), + Cmd.info "seek_id" ~doc ~sdocs ~exits ~man ) let seek_cur_t = let doc = "Play the current song at TIME" in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] in - Term.(const seek_cur $ common_opts_t $ time), - Term.info "seek_cur" ~doc ~sdocs ~exits ~man + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const seek_cur $ common_opts_t $ time), + Cmd.info "seek_cur" ~doc ~sdocs ~exits ~man ) let next common_opts = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.next client in Mpd.Client.close client let next_t = - let doc = "Play the next song in the playlist" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const next $ common_opts_t), - Term.info "next" ~doc ~sdocs ~exits ~man + let doc = "Play the next song in the playlist" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + (Term.(const next $ common_opts_t), Cmd.info "next" ~doc ~sdocs ~exits ~man) let previous common_opts = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.previous client in Mpd.Client.close client let previous_t = - let doc = "Play the previous song in the playlist" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const previous $ common_opts_t), - Term.info "previous" ~doc ~sdocs ~exits ~man + let doc = "Play the previous song in the playlist" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const previous $ common_opts_t), + Cmd.info "previous" ~doc ~sdocs ~exits ~man ) let stop common_opts = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.stop client in Mpd.Client.close client let stop_t = - let doc = "Stop playing song." - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const stop $ common_opts_t), - Term.info "stop" ~doc ~sdocs ~exits ~man + let doc = "Stop playing song." in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + (Term.(const stop $ common_opts_t), Cmd.info "stop" ~doc ~sdocs ~exits ~man) let pause common_opts value = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let _ = check_for_mpd_error @@ Mpd.Playback.pause client value in Mpd.Client.close client @@ -177,14 +142,20 @@ let toggle_value = Arg.(value & pos 0 bool true & info [] ~doc ~docv:"TOGGLE_VAL") let pause_t = - let doc = "Switch between play/pause." - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const pause $ common_opts_t $ toggle_value), - Term.info "pause" ~doc ~sdocs ~exits ~man - -let cmds = [play_t; play_id_t; seek_t; seek_id_t; seek_cur_t; next_t; previous_t; stop_t; pause_t] + let doc = "Switch between play/pause." in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const pause $ common_opts_t $ toggle_value), + Cmd.info "pause" ~doc ~sdocs ~exits ~man ) + +let cmds = + [ + play_t; + play_id_t; + seek_t; + seek_id_t; + seek_cur_t; + next_t; + previous_t; + stop_t; + pause_t; + ] diff --git a/bin/Ompdc_playback_options.ml b/bin/Ompdc_playback_options.ml index f53fd22..1814081 100644 --- a/bin/Ompdc_playback_options.ml +++ b/bin/Ompdc_playback_options.ml @@ -18,77 +18,97 @@ open Cmdliner open Ompdc_common - module Pb_opt = Mpd.Playback_options let consume = - let doc = "Sets consume state to STATE, STATE should be false or true. - When consume is activated, each song played is removed from playlist." in + let doc = + "Sets consume state to STATE, STATE should be false or true.\n\ + \ When consume is activated, each song played is removed from playlist." + in let docv = "STATE" in - Arg.(value & opt (some bool) None & info ["c"; "consume"] ~docs ~doc ~docv) + Arg.(value & opt (some bool) None & info [ "c"; "consume" ] ~docs ~doc ~docv) let crossfade = let doc = "Sets crossfade XFADE between songs in seconds." in let docv = "XFADE" in - Arg.(value & opt (some int) None & info ["xf"; "crossfade"] ~docs ~doc ~docv) + Arg.( + value & opt (some int) None & info [ "xf"; "crossfade" ] ~docs ~doc ~docv) let mixrampdb = - let doc = "Sets the threshold at which songs will be overlapped. - Like crossfading but doesn't fade the track volume, just overlaps. The - songs need to have MixRamp tags added by an external tool. 0dB is the - normalized maximum volume so use negative values, I prefer -17dB. - In the absence of mixramp tags crossfading will be used. - See http://sourceforge.net/projects/mixramp" in + let doc = + "Sets the threshold at which songs will be overlapped.\n\ + \ Like crossfading but doesn't fade the track volume, just overlaps. The\n\ + \ songs need to have MixRamp tags added by an external tool. 0dB is the\n\ + \ normalized maximum volume so use negative values, I prefer -17dB.\n\ + \ In the absence of mixramp tags crossfading will be used.\n\ + \ See http://sourceforge.net/projects/mixramp" + in let docv = "MIXRAMPDB" in - Arg.(value & opt (some int) None & info ["mixrampdb"] ~docs ~doc ~docv) + Arg.(value & opt (some int) None & info [ "mixrampdb" ] ~docs ~doc ~docv) let random = - let doc = "Sets random state to RAND_STATE, RAND_STATE should be true or - false" in + let doc = + "Sets random state to RAND_STATE, RAND_STATE should be true or\n false" + in let docv = "RAND_STATE" in - Arg.(value & opt (some bool) None & info ["rand"; "random"] ~docs ~doc ~docv) + Arg.( + value & opt (some bool) None & info [ "rand"; "random" ] ~docs ~doc ~docv) let repeat = - let doc = "Sets repeat state to REPEAT_STATE, REPEAT_STATE should be false \ - or true." in + let doc = + "Sets repeat state to REPEAT_STATE, REPEAT_STATE should be false or true." + in let docv = "REPEAT_STATE" in - Arg.(value & opt (some bool) None & info ["rep"; "repeat"] ~docs ~doc ~docv) + Arg.(value & opt (some bool) None & info [ "rep"; "repeat" ] ~docs ~doc ~docv) let setvol = let doc = "Sets volume to VOL, the range of volume is 0-100" in let docv = "VOL" in - Arg.(value & opt (some int) None & info ["vol"; "volume"] ~docs ~doc ~docv) + Arg.(value & opt (some int) None & info [ "vol"; "volume" ] ~docs ~doc ~docv) let single = - let doc = "Sets single state to SINGLE_STATE, SINGLE_STATE should be 0 or 1. When single is - activated, playback is stopped after current song, or song is repeated if - the 'repeat' mode is enabled." in + let doc = + "Sets single state to SINGLE_STATE, SINGLE_STATE should be 0 or 1. When \ + single is\n\ + \ activated, playback is stopped after current song, or song is \ + repeated if\n\ + \ the 'repeat' mode is enabled." + in let docv = "SINGLE_STATE" in - Arg.(value & opt (some bool) None & info ["single"] ~docs ~doc ~docv) + Arg.(value & opt (some bool) None & info [ "single" ] ~docs ~doc ~docv) let mixrampdelay = - let doc = "Additional time subtracted from the overlap calculated by mixrampdb. A - value of \"nan\" disables MixRamp overlapping and falls back to crossfading." in + let doc = + "Additional time subtracted from the overlap calculated by mixrampdb. A\n\ + \ value of \"nan\" disables MixRamp overlapping and falls back to \ + crossfading." + in let docv = "MIXRAMP_DELAY" in - Arg.(value & opt (some string) None & info ["mixrampdelay"] ~docs ~doc ~docv) + Arg.( + value & opt (some string) None & info [ "mixrampdelay" ] ~docs ~doc ~docv) let mixrampdelay_wrapper client value = let string_parse str = match str with | "nan" -> Pb_opt.Nan - | _ -> try Pb_opt.Seconds (float_of_string str) - with Failure _ -> Pb_opt.Nan + | _ -> ( + try Pb_opt.Seconds (float_of_string str) with Failure _ -> Pb_opt.Nan) in Pb_opt.mixrampdelay client (string_parse value) let replay_gain_mode = - let doc = "Sets the replay gain mode. One of off, track, album, auto with - default (value given) set to auto. - Changing the mode during playback may take several seconds, because the - new settings does not affect the buffered data. - This command triggers the options idle event." in + let doc = + "Sets the replay gain mode. One of off, track, album, auto with\n\ + \ default (value given) set to auto.\n\ + \ Changing the mode during playback may take several seconds, because the\n\ + \ new settings does not affect the buffered data.\n\ + \ This command triggers the options idle event." + in let docv = "REPLAY_GAIN_MODE" in - Arg.(value & opt (some string) None & info ["replay_gain_mode"] ~docs ~doc ~docv) + Arg.( + value + & opt (some string) None + & info [ "replay_gain_mode" ] ~docs ~doc ~docv) let replay_gain_mode_wrapper client value = let string_parse = function @@ -97,12 +117,13 @@ let replay_gain_mode_wrapper client value = | "off" -> Pb_opt.Off | "track" -> Pb_opt.Track | _ -> Pb_opt.Auto - in Pb_opt.replay_gain_mode client (string_parse value) + in + Pb_opt.replay_gain_mode client (string_parse value) let playback_options common_opts consume crossfade mixrampdb random repeat - setvol single mixrampdelay replay_gain_mode = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + setvol single mixrampdelay replay_gain_mode = + let { host; port } = common_opts in + let client = initialize_client { host; port } in let on_value_do opt_val fn = match opt_val with | Some v -> check_for_mpd_error (fn client v) @@ -120,14 +141,9 @@ let playback_options common_opts consume crossfade mixrampdb random repeat Mpd.Client.close client let cmd = - let doc = "Configure all the playback options of the Mpd server." - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const playback_options $ common_opts_t $ consume $ crossfade - $ mixrampdb $ random $ repeat $ setvol - $ single $ mixrampdelay $ replay_gain_mode), - Term.info "playback_options" ~doc ~sdocs ~exits ~man + let doc = "Configure all the playback options of the Mpd server." in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.( + const playback_options $ common_opts_t $ consume $ crossfade $ mixrampdb + $ random $ repeat $ setvol $ single $ mixrampdelay $ replay_gain_mode), + Cmd.info "playback_options" ~doc ~sdocs ~exits ~man ) diff --git a/bin/Ompdc_status.ml b/bin/Ompdc_status.ml index 0015803..e7f2376 100644 --- a/bin/Ompdc_status.ml +++ b/bin/Ompdc_status.ml @@ -67,86 +67,140 @@ let get_info_str = function | Updating_db -> "updating_db" | Error -> "error" - let get_mpd_status_info status = function - | Volume -> ["volume:"; string_of_int @@ Mpd.Status.volume status] - | Repeat -> ["repeat:"; string_of_bool @@ Mpd.Status.repeat status] - | Random -> ["random:"; string_of_bool @@ Mpd.Status.random status] - | Single -> ["single:"; string_of_bool @@ Mpd.Status.single status] - | Consume -> ["consume:"; string_of_bool @@ Mpd.Status.consume status] - | Playlist ->["playlist:"; string_of_int @@ Mpd.Status.playlist status] - | Playlistlength -> ["playlistlength:"; - string_of_int @@ Mpd.Status.playlistlength status] - | State -> let state = Mpd.Status.state status in - ["state:"; Mpd.Status.string_of_state state] - | Song -> ["song:"; string_of_int @@ Mpd.Status.song status] - | Songid -> ["songid:"; string_of_int @@ Mpd.Status.songid status] - | Nextsong -> ["nextsong:"; string_of_int @@ Mpd.Status.nextsong status] - | Nextsongid -> ["nextsongid:"; string_of_int @@ Mpd.Status.nextsongid status] - | Time -> ["time:"; Mpd.Status.time status] - | Elapsed -> ["elapsed:"; string_of_float @@ Mpd.Status.elapsed status] - | Duration -> ["duration:"; string_of_float @@ Mpd.Status.duration status] - | Bitrate -> ["bitrate:"; string_of_int @@ Mpd.Status.bitrate status] - | Xfade -> ["xfade:"; string_of_int @@ Mpd.Status.xfade status] - | Mixrampdb -> ["mixrampdb:"; string_of_float @@ Mpd.Status.mixrampdb status] - | Mixrampdelay -> ["mixrampdelay:"; string_of_float @@ Mpd.Status.mixrampdelay status] - | Audio -> ["audio:"; Mpd.Status.audio status] - | Updating_db -> ["updating_db:"; string_of_int @@ Mpd.Status.updating_db status] - | Error -> ["error:"; Mpd.Status.error status] - + | Volume -> [ "volume:"; string_of_int @@ Mpd.Status.volume status ] + | Repeat -> [ "repeat:"; string_of_bool @@ Mpd.Status.repeat status ] + | Random -> [ "random:"; string_of_bool @@ Mpd.Status.random status ] + | Single -> [ "single:"; string_of_bool @@ Mpd.Status.single status ] + | Consume -> [ "consume:"; string_of_bool @@ Mpd.Status.consume status ] + | Playlist -> [ "playlist:"; string_of_int @@ Mpd.Status.playlist status ] + | Playlistlength -> + [ "playlistlength:"; string_of_int @@ Mpd.Status.playlistlength status ] + | State -> + let state = Mpd.Status.state status in + [ "state:"; Mpd.Status.string_of_state state ] + | Song -> [ "song:"; string_of_int @@ Mpd.Status.song status ] + | Songid -> [ "songid:"; string_of_int @@ Mpd.Status.songid status ] + | Nextsong -> [ "nextsong:"; string_of_int @@ Mpd.Status.nextsong status ] + | Nextsongid -> + [ "nextsongid:"; string_of_int @@ Mpd.Status.nextsongid status ] + | Time -> [ "time:"; Mpd.Status.time status ] + | Elapsed -> [ "elapsed:"; string_of_float @@ Mpd.Status.elapsed status ] + | Duration -> [ "duration:"; string_of_float @@ Mpd.Status.duration status ] + | Bitrate -> [ "bitrate:"; string_of_int @@ Mpd.Status.bitrate status ] + | Xfade -> [ "xfade:"; string_of_int @@ Mpd.Status.xfade status ] + | Mixrampdb -> + [ "mixrampdb:"; string_of_float @@ Mpd.Status.mixrampdb status ] + | Mixrampdelay -> + [ "mixrampdelay:"; string_of_float @@ Mpd.Status.mixrampdelay status ] + | Audio -> [ "audio:"; Mpd.Status.audio status ] + | Updating_db -> + [ "updating_db:"; string_of_int @@ Mpd.Status.updating_db status ] + | Error -> [ "error:"; Mpd.Status.error status ] let get_status common_opts fields = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in match Mpd.Client.status client with | Error message -> print_endline message | Ok status -> let rec _parse_fields = function | [] -> () - | i :: remain -> let info = String.concat " " @@ get_mpd_status_info status i in - let _ = print_endline info in - _parse_fields remain - in - let _ = _parse_fields fields in - Mpd.Client.close client + | i :: remain -> + let info = String.concat " " @@ get_mpd_status_info status i in + let _ = print_endline info in + _parse_fields remain + in + let _ = _parse_fields fields in + Mpd.Client.close client let status_fields = - let volume = Volume, Arg.info ["v"; "volume"; "vol"] in - let repeat = Repeat, Arg.info ["r"; "repeat"] in - let random = Random, Arg.info ["rand"; "random"] in - let single = Single, Arg.info ["single"] in - let consume = Consume, Arg.info ["c"; "consume"] in - let playlist = Playlist, Arg.info ["plist"; "playlist"] in - let playlistlength = Playlistlength, Arg.info ["plistl"; "playlistlength"] in - let state = State, Arg.info ["st"; "state"] in - let song = Song, Arg.info ["so"; "song"] in - let songid = Songid, Arg.info ["soid"; "songid"] in - let nextsong = Nextsong, Arg.info ["nso"; "nextsong"] in - let nextsongid = Nextsongid, Arg.info ["nsoid"; "nextsongid"] in - let time = Time, Arg.info ["t"; "time"] in - let elapsed = Elapsed, Arg.info ["e"; "elapsed"] in - let duration = Duration, Arg.info ["d"; "duration"] in - let bitrate = Bitrate, Arg.info ["b"; "bitrate"] in - let xfade = Xfade, Arg.info ["x"; "xfade"] in - let mixrampdb = Mixrampdb, Arg.info ["mixdb"; "mixrampdb"] in - let mixrampdelay = Mixrampdelay, Arg.info ["mixdelay"; "mixrampdelay"] in - let audio = Audio, Arg.info ["a"; "audio"] in - let updating_db = Updating_db, Arg.info ["u"; "Updating_db"] in - let error = Error, Arg.info ["err"; "error"] in - Arg.(value & vflag_all [Volume; Repeat; Random; Single; Consume; Playlist; - Playlistlength; State; Song; Songid; Nextsong; - Nextsongid; Time; Elapsed; Duration; Bitrate; Xfade; - Mixrampdb; Mixrampdelay; Audio; Updating_db; Error] - [volume; repeat; random; single; consume; playlist; - playlistlength; state; song; songid; nextsong; - nextsongid; time; elapsed; duration; bitrate; xfade; - mixrampdb; mixrampdelay; audio; updating_db; error]) + let volume = (Volume, Arg.info [ "v"; "volume"; "vol" ]) in + let repeat = (Repeat, Arg.info [ "r"; "repeat" ]) in + let random = (Random, Arg.info [ "rand"; "random" ]) in + let single = (Single, Arg.info [ "single" ]) in + let consume = (Consume, Arg.info [ "c"; "consume" ]) in + let playlist = (Playlist, Arg.info [ "plist"; "playlist" ]) in + let playlistlength = + (Playlistlength, Arg.info [ "plistl"; "playlistlength" ]) + in + let state = (State, Arg.info [ "st"; "state" ]) in + let song = (Song, Arg.info [ "so"; "song" ]) in + let songid = (Songid, Arg.info [ "soid"; "songid" ]) in + let nextsong = (Nextsong, Arg.info [ "nso"; "nextsong" ]) in + let nextsongid = (Nextsongid, Arg.info [ "nsoid"; "nextsongid" ]) in + let time = (Time, Arg.info [ "t"; "time" ]) in + let elapsed = (Elapsed, Arg.info [ "e"; "elapsed" ]) in + let duration = (Duration, Arg.info [ "d"; "duration" ]) in + let bitrate = (Bitrate, Arg.info [ "b"; "bitrate" ]) in + let xfade = (Xfade, Arg.info [ "x"; "xfade" ]) in + let mixrampdb = (Mixrampdb, Arg.info [ "mixdb"; "mixrampdb" ]) in + let mixrampdelay = (Mixrampdelay, Arg.info [ "mixdelay"; "mixrampdelay" ]) in + let audio = (Audio, Arg.info [ "a"; "audio" ]) in + let updating_db = (Updating_db, Arg.info [ "u"; "Updating_db" ]) in + let error = (Error, Arg.info [ "err"; "error" ]) in + Arg.( + value + & vflag_all + [ + Volume; + Repeat; + Random; + Single; + Consume; + Playlist; + Playlistlength; + State; + Song; + Songid; + Nextsong; + Nextsongid; + Time; + Elapsed; + Duration; + Bitrate; + Xfade; + Mixrampdb; + Mixrampdelay; + Audio; + Updating_db; + Error; + ] + [ + volume; + repeat; + random; + single; + consume; + playlist; + playlistlength; + state; + song; + songid; + nextsong; + nextsongid; + time; + elapsed; + duration; + bitrate; + xfade; + mixrampdb; + mixrampdelay; + audio; + updating_db; + error; + ]) let cmd = - let doc = "Get all status information with no arguments or chose those you want." in - let man = [ `S Manpage.s_description; - `P "Status commands in order to display Mpd server information."; - `Blocks help_section - ] in - Term.(const get_status $ common_opts_t $ status_fields), - Term.info "status" ~doc ~sdocs ~exits ~man + let doc = + "Get all status information with no arguments or chose those you want." + in + let man = + [ + `S Manpage.s_description; + `P "Status commands in order to display Mpd server information."; + `Blocks help_section; + ] + in + ( Term.(const get_status $ common_opts_t $ status_fields), + Cmd.info "status" ~doc ~sdocs ~exits ~man ) diff --git a/bin/Ompdc_stored_playlists.ml b/bin/Ompdc_stored_playlists.ml index 8e9570c..2ac1c63 100644 --- a/bin/Ompdc_stored_playlists.ml +++ b/bin/Ompdc_stored_playlists.ml @@ -20,25 +20,19 @@ open Cmdliner open Ompdc_common let listplaylists common_opts = - let {host; port} = common_opts in - let client = initialize_client {host; port} in - let () = match Mpd.Stored_playlists.listplaylists client with + let { host; port } = common_opts in + let client = initialize_client { host; port } in + let () = + match Mpd.Stored_playlists.listplaylists client with | Error message -> print_endline message | Ok playlists -> List.iter print_endline playlists in Mpd.Client.close client let listplaylists_t = - let doc = "List all the playlists" - in - let man = [ - `S Manpage.s_description; - `P doc; - `Blocks help_section; ] - in - Term.(const listplaylists $ common_opts_t), - Term.info "listplaylists" ~doc ~sdocs ~exits ~man - -let cmds = [listplaylists_t] - + let doc = "List all the playlists" in + let man = [ `S Manpage.s_description; `P doc; `Blocks help_section ] in + ( Term.(const listplaylists $ common_opts_t), + Cmd.info "listplaylists" ~doc ~sdocs ~exits ~man ) +let cmds = [ listplaylists_t ] diff --git a/bin/dune b/bin/dune index d6c7c1f..d15be45 100644 --- a/bin/dune +++ b/bin/dune @@ -1,5 +1,4 @@ (executable - (name ompdc) - (public_name ompdc) - (libraries libmpdclient lwt lwt.unix cmdliner notty notty.lwt unix) -) + (name ompdc) + (public_name ompdc) + (libraries libmpdclient lwt lwt.unix cmdliner notty notty.lwt unix)) diff --git a/bin/ompdc.ml b/bin/ompdc.ml index e06b82c..accc34a 100644 --- a/bin/ompdc.ml +++ b/bin/ompdc.ml @@ -19,18 +19,20 @@ open Cmdliner open Ompdc_common -let default_cmd = +let default = Term.(ret (const (fun _ -> `Help (`Pager, None)) $ common_opts_t)) + +let cmd_info = let doc = "a Mpd client written in OCaml." in let man = help_section in - Term.(ret (const (fun _ -> `Help (`Pager, None)) $ common_opts_t)), - Term.info "ompdc" ~version ~doc ~sdocs ~exits ~man + Cmd.info ~version ~doc ~sdocs ~exits ~man "ompdc" -let cmds = List.concat [Ompdc_playback.cmds; - Ompdc_stored_playlists.cmds; - [Ompdc_status.cmd; - Ompdc_idle.cmd; - Ompdc_playback_options.cmd; - help_cmd] - ] +let cmds = + List.concat + [ + Ompdc_playback.cmds; + Ompdc_stored_playlists.cmds; + [ Ompdc_status.cmd; Ompdc_idle.cmd; Ompdc_playback_options.cmd; help_cmd ]; + ] + |> List.map (fun t -> Cmd.v (snd t) (fst t)) -let () = Term.(exit @@ eval_choice default_cmd cmds) +let () = exit @@ Cmd.(eval @@ group ~default cmd_info cmds) diff --git a/bin/ompdc_bad_implementation.ml b/bin/ompdc_bad_implementation.ml index 45c3cfb..edad211 100644 --- a/bin/ompdc_bad_implementation.ml +++ b/bin/ompdc_bad_implementation.ml @@ -23,48 +23,60 @@ let sdocs = Manpage.s_common_options let docs = Manpage.s_common_options let exits = Term.default_exits -let help copts man_format cmds topic = match topic with -| None -> `Help (`Pager, None) (* help about the program. *) -| Some topic -> - let topics = "topics" :: "patterns" :: "environment" :: cmds in - let conv, _ = Cmdliner.Arg.enum (List.rev_map (fun s -> (s, s)) topics) in - match conv topic with - | `Error e -> `Error (false, e) - | `Ok t when t = "topics" -> List.iter print_endline topics; `Ok () - | `Ok t when List.mem t cmds -> `Help (man_format, Some t) - | `Ok t -> - let page = (topic, 7, "", "", ""), [`S topic; `P "Say something";] in - `Ok (Cmdliner.Manpage.print man_format Format.std_formatter page) +let help copts man_format cmds topic = + match topic with + | None -> `Help (`Pager, None) (* help about the program. *) + | Some topic -> ( + let topics = "topics" :: "patterns" :: "environment" :: cmds in + let conv, _ = Cmdliner.Arg.enum (List.rev_map (fun s -> (s, s)) topics) in + match conv topic with + | `Error e -> `Error (false, e) + | `Ok t when t = "topics" -> + List.iter print_endline topics; + `Ok () + | `Ok t when List.mem t cmds -> `Help (man_format, Some t) + | `Ok t -> + let page = + ((topic, 7, "", "", ""), [ `S topic; `P "Say something" ]) + in + `Ok (Cmdliner.Manpage.print man_format Format.std_formatter page)) (* Help sections common to all commands *) -let help_section = [ - `S Manpage.s_common_options; - `P "These options are common to all commands."; - `S Manpage.s_bugs; `P "Check bug reports at https://github.com/cedlemo/OCaml-libmpdclient/issues"; - `S Manpage.s_authors; `P "Cedric Le Moigne " - ] +let help_section = + [ + `S Manpage.s_common_options; + `P "These options are common to all commands."; + `S Manpage.s_bugs; + `P + "Check bug reports at \ + https://github.com/cedlemo/OCaml-libmpdclient/issues"; + `S Manpage.s_authors; + `P "Cedric Le Moigne "; + ] (* Options common to all commands *) -type mpd_opts = {host : string; port : int} +type mpd_opts = { host : string; port : int } -let common_opts host port = - {host; port} +let common_opts host port = { host; port } let common_opts_t = let host = let doc = "Set the address of the Mpd server." in let env = Arg.env_var "OMPDC_HOST" ~doc in - Arg.(value & opt string "127.0.0.1" & info ["h"; "host"] ~docs ~env ~docv:"HOST") + Arg.( + value & opt string "127.0.0.1" + & info [ "h"; "host" ] ~docs ~env ~docv:"HOST") in let port = let doc = "Set the port of the Mpd server." in let env = Arg.env_var "OMPDC_PORT" ~doc in - Arg.(value & opt int 6600 & info ["p"; "port"] ~docs ~env ~docv:"PORT") + Arg.(value & opt int 6600 & info [ "p"; "port" ] ~docs ~env ~docv:"PORT") in Term.(const common_opts $ host $ port) type playback_cmds = Play | Next | Prev | Pause | Stop + let playback_cmds_to_string = function | Next -> "next" | Pause -> "pause" @@ -72,17 +84,18 @@ let playback_cmds_to_string = function | Prev -> "prev" | Stop -> "stop" -let initialize_client {host; port} = - let connection = Mpd.Connection.initialize host port in - let client = Mpd.Client.initialize connection in - let _ = print_endline ("Mpd server : " ^ (Mpd.Client.mpd_banner client)) in - client +let initialize_client { host; port } = + let connection = Mpd.Connection.initialize host port in + let client = Mpd.Client.initialize connection in + let _ = print_endline ("Mpd server : " ^ Mpd.Client.mpd_banner client) in + client let playback common_opts cmd = - let {host; port} = common_opts in - let client = initialize_client {host; port} in + let { host; port } = common_opts in + let client = initialize_client { host; port } in let cmd_str = playback_cmds_to_string cmd in - let _ = match cmd with + let _ = + match cmd with | Next -> ignore (Mpd.Playback.next client) | Pause -> ignore (Mpd.Playback.pause client true) | Play -> ignore (Mpd.Playback.play client 1) @@ -93,28 +106,29 @@ let playback common_opts cmd = print_endline message let playback_action = - let doc = "Play next song." in - let next = Next, Arg.info ["next"] ~doc in - let doc = "Toggle Play/Stop." in - let pause = Pause, Arg.info ["pause"] ~doc in - let doc = "Play the current song in the Mpd queue." in - let play = Play, Arg.info ["play"] ~doc in - let doc = "Stop playing songs." in - let stop = Stop, Arg.info ["stop"] ~doc in - let doc = "Play previous song." in - let prev = Prev, Arg.info ["prev"] ~doc in - Arg.(last & vflag_all [Pause] [next; pause; play; prev; stop]) + let doc = "Play next song." in + let next = (Next, Arg.info [ "next" ] ~doc) in + let doc = "Toggle Play/Stop." in + let pause = (Pause, Arg.info [ "pause" ] ~doc) in + let doc = "Play the current song in the Mpd queue." in + let play = (Play, Arg.info [ "play" ] ~doc) in + let doc = "Stop playing songs." in + let stop = (Stop, Arg.info [ "stop" ] ~doc) in + let doc = "Play previous song." in + let prev = (Prev, Arg.info [ "prev" ] ~doc) in + Arg.(last & vflag_all [ Pause ] [ next; pause; play; prev; stop ]) let playback_t = - let doc = "Playback commands" - in - let man = [ - `S Manpage.s_description; - `P "Playback commands for the current playlist (queue)."; - `Blocks help_section; ] - in - Term.(const playback $ common_opts_t $ playback_action), - Term.info "playback" ~doc ~sdocs ~exits ~man + let doc = "Playback commands" in + let man = + [ + `S Manpage.s_description; + `P "Playback commands for the current playlist (queue)."; + `Blocks help_section; + ] + in + ( Term.(const playback $ common_opts_t $ playback_action), + Term.info "playback" ~doc ~sdocs ~exits ~man ) let help_cmd = let topic = @@ -123,56 +137,57 @@ let help_cmd = in let doc = "display help about ompdc and ompdc commands" in let man = - [`S Manpage.s_description; - `P "Prints help about ompdc commands and other subjects..."; - `Blocks help_section; ] + [ + `S Manpage.s_description; + `P "Prints help about ompdc commands and other subjects..."; + `Blocks help_section; + ] in - Term.(ret - (const help $ common_opts_t $ Arg.man_format $ Term.choice_names $topic)), - Term.info "help" ~doc ~exits ~man + ( Term.( + ret + (const help $ common_opts_t $ Arg.man_format $ Term.choice_names $ topic)), + Term.info "help" ~doc ~exits ~man ) let default_cmd = let doc = "a Mpd client written in OCaml." in let man = help_section in - Term.(ret (const (fun _ -> `Help (`Pager, None)) $ common_opts_t)), - Term.info "ompdc" ~version ~doc ~sdocs ~exits ~man - -let cmds = [playback_t; help_cmd] + ( Term.(ret (const (fun _ -> `Help (`Pager, None)) $ common_opts_t)), + Term.info "ompdc" ~version ~doc ~sdocs ~exits ~man ) +let cmds = [ playback_t; help_cmd ] let () = Term.(exit @@ eval_choice default_cmd cmds) (* let playback common_opts cmd args = - let show_message host port cmd args = - let _args = match args with | None -> "no args" | Some s -> s in - let message = Printf.sprintf "%s:%d %s %s" host port cmd _args in - print_endline message - in - let {host; port} = common_opts in - match cmd with - | `Next -> show_message host port "next" args - | `Pause -> show_message host port "pause" args - | `Play -> show_message host port "play" args - | `Prev -> show_message host port "prev" args - | `Stop -> show_message host port "stop" args - -let playback_actions = - let actions = ["play", `Play; - "stop", `Stop; - "prev", `Prev; - "next", `Next; - "pause", `Pause - ] in - let substitue = Printf.sprintf in - let action_docs = List.map (fun (str, sym) -> - match sym with - | `Play -> substitue "$(b,%s) [ARG]" str - | `Pause -> substitue "$(b,%s) [ARG]" str - | `Stop | `Prev | `Next -> substitue "$(b,%s)" str - ) actions in - let doc = substitue "The action to perform. $(docv) must be one of: %s." - (String.concat ", " action_docs) - in - let action = Arg.enum actions in - Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION") + let show_message host port cmd args = + let _args = match args with | None -> "no args" | Some s -> s in + let message = Printf.sprintf "%s:%d %s %s" host port cmd _args in + print_endline message + in + let {host; port} = common_opts in + match cmd with + | `Next -> show_message host port "next" args + | `Pause -> show_message host port "pause" args + | `Play -> show_message host port "play" args + | `Prev -> show_message host port "prev" args + | `Stop -> show_message host port "stop" args + + let playback_actions = + let actions = ["play", `Play; + "stop", `Stop; + "prev", `Prev; + "next", `Next; + "pause", `Pause + ] in + let substitue = Printf.sprintf in + let action_docs = List.map (fun (str, sym) -> + match sym with + | `Play -> substitue "$(b,%s) [ARG]" str + | `Pause -> substitue "$(b,%s) [ARG]" str + | `Stop | `Prev | `Next -> substitue "$(b,%s)" str + ) actions in + let doc = substitue "The action to perform. $(docv) must be one of: %s." + (String.concat ", " action_docs) + in + let action = Arg.enum actions in + Arg.(required & pos 0 (some action) None & info [] ~doc ~docv:"ACTION") *) - diff --git a/docs/Mpd__Client/.dune-keep b/docs/Mpd/.dummy similarity index 100% rename from docs/Mpd__Client/.dune-keep rename to docs/Mpd/.dummy diff --git a/docs/Mpd/Client/index.html b/docs/Mpd/Client/index.html index aaff6f4..0df5de3 100644 --- a/docs/Mpd/Client/index.html +++ b/docs/Mpd/Client/index.html @@ -1,2 +1,2 @@ -Client (libmpdclient.Mpd.Client)

Module Mpd.Client

type t

Client type

val initialize : Connection.t -> t

Initialize the client with a connection.

val send_request : t -> string -> Protocol.response
val send_command : t -> string -> Protocol.response
val mpd_banner : t -> string

Return the mpd banner that the server send at the first connection of the client.

val status : t -> (Status.t, string) Stdlib.result

Create a status request and returns the status under a Mpd.Status.t type if no error occurs.

val ping : t -> Protocol.response

Does nothing but return "OK".

val password : t -> string -> Protocol.response

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val close : t -> unit

Close the connection to MPD. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

val tagtypes : t -> string list

Show a list of available tag types. It is an intersection of the metadata_to_use setting and this client's tag mask. About the tag mask: each client can decide to disable any number of tag types, which will be omitted from responses to this client. That is a good idea, because it makes responses smaller. The following tagtypes sub commands configure this list.

\ No newline at end of file +Client (libmpdclient.Mpd.Client)

Module Mpd.Client

Provides functions and type in order to communicate to the mpd server with commands and requests.

type t

Client type

val initialize : Connection.t -> t

Initialize the client with a connection.

val send: t -> string -> Protocol.response Send to the mpd server a command or a request. The response of the server is returned under the form of a Protocol.response type.

val send_request : t -> string -> Protocol.response
val send_command : t -> string -> Protocol.response
val mpd_banner : t -> string

Return the mpd banner that the server send at the first connection of the client.

val status : t -> (Status.t, string) Stdlib.result

Create a status request and returns the status under a Mpd.Status.t type if no error occurs.

val ping : t -> Protocol.response

Does nothing but return "OK".

val password : t -> string -> Protocol.response

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val close : t -> unit

Close the connection to MPD. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

val tagtypes : t -> string list

Show a list of available tag types. It is an intersection of the metadata_to_use setting and this client's tag mask. About the tag mask: each client can decide to disable any number of tag types, which will be omitted from responses to this client. That is a good idea, because it makes responses smaller. The following tagtypes sub commands configure this list.

\ No newline at end of file diff --git a/docs/Mpd/Client_lwt/index.html b/docs/Mpd/Client_lwt/index.html index 696b664..b143ed7 100644 --- a/docs/Mpd/Client_lwt/index.html +++ b/docs/Mpd/Client_lwt/index.html @@ -1,2 +1,2 @@ -Client_lwt (libmpdclient.Mpd.Client_lwt)

Module Mpd.Client_lwt

type t

Type for a Mpd Client to be used with Lwt promises.

val initialize : Connection_lwt.t -> t Lwt.t

Initialize the client with a connection.

val mpd_banner : t -> string Lwt.t

Return the mpd banner that the server send at the first connection of the client.

val idle : t -> (string, string) Stdlib.Pervasives.result Lwt.t

Wait for an event to occur in order to return. When a Client send this * command to the Mpd server throught its connection, the Mpd server do * not answer to any other command except the noidle command. The idea is * to first cancel the promise that has send the "idle" command with * Lwt.cancel and then send the noidle command to the Mpd server. An * example can be found in samples/mpd_lwt_client_idle_noidle.ml.

val idle_loop : t -> (string -> bool Lwt.t) -> unit Lwt.t

Loop on mpd event with the "idle" command the on_event function take the event response as argument and return true to stop or false to continue the loop

val send : t -> string -> Protocol.response Lwt.t

Send to the mpd server a command. The response of the server is returned under the form of a Protocol.response type.

val request : t -> string -> Protocol.response Lwt.t

Send to the mpd server a request. The response of the server is returned under the form of a Protocol.response type. A request is different from a command because a command generate an action from Mpd and returns "OK" or an error while a request does not generate an action from Mpd and returns "some data to analyse"OK or an error.

val status : t -> (Status.t, string) Stdlib.Pervasives.result Lwt.t

Create a status request and returns the status under a Mpd.Status.s Lwt.t type.

val ping : t -> Protocol.response Lwt.t

Does nothing but return "OK".

val password : t -> string -> Protocol.response Lwt.t

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val noidle : t -> Protocol.response Lwt.t

This command is needed to stop listening after a Client.idle command. An example of usage can be seen in samples/mpd_lwt_client_idle_noidle.exe.

val close : t -> unit Lwt.t

Close the client. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

\ No newline at end of file +Client_lwt (libmpdclient.Mpd.Client_lwt)

Module Mpd.Client_lwt

Provides functions and type in order to communicate to the mpd server with commands and requests in Lwt threads.

type t

Type for a Mpd Client to be used with Lwt promises.

val initialize : Connection_lwt.t -> t Lwt.t

Initialize the client with a connection.

val mpd_banner : t -> string Lwt.t

Return the mpd banner that the server send at the first connection of the client.

val idle : t -> (string, string) Stdlib.result Lwt.t

Wait for an event to occur in order to return. When a Client send this * command to the Mpd server throught its connection, the Mpd server do * not answer to any other command except the noidle command. The idea is * to first cancel the promise that has send the "idle" command with * Lwt.cancel and then send the noidle command to the Mpd server. An * example can be found in samples/mpd_lwt_client_idle_noidle.ml.

val idle_loop : t -> (string -> bool Lwt.t) -> unit Lwt.t

Loop on mpd event with the "idle" command the on_event function take the event response as argument and return true to stop or false to continue the loop

val send : t -> string -> Protocol.response Lwt.t

Send to the mpd server a command. The response of the server is returned under the form of a Protocol.response type.

val request : t -> string -> Protocol.response Lwt.t

Send to the mpd server a request. The response of the server is returned under the form of a Protocol.response type. A request is different from a command because a command generate an action from Mpd and returns "OK" or an error while a request does not generate an action from Mpd and returns "some data to analyse"OK or an error.

val status : t -> (Status.t, string) Stdlib.result Lwt.t

Create a status request and returns the status under a Mpd.Status.s Lwt.t type.

val ping : t -> Protocol.response Lwt.t

Does nothing but return "OK".

val password : t -> string -> Protocol.response Lwt.t

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val noidle : t -> Protocol.response Lwt.t

This command is needed to stop listening after a Client.idle command. An example of usage can be seen in samples/mpd_lwt_client_idle_noidle.exe.

val close : t -> unit Lwt.t

Close the client. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

\ No newline at end of file diff --git a/docs/Mpd/Connection/index.html b/docs/Mpd/Connection/index.html index dec248d..50750b0 100644 --- a/docs/Mpd/Connection/index.html +++ b/docs/Mpd/Connection/index.html @@ -1,2 +1,2 @@ -Connection (libmpdclient.Mpd.Connection)

Module Mpd.Connection

type t

connection type

val initialize : string -> int -> t

Create the connection, exit if the connection can not be initialized.

val hostname : t -> string

Retrieve the host's string of the initialized connection.

val port : t -> int

Retrieve the port of the connection of the initialized connection.

val close : t -> unit

Close the connection

val write : t -> string -> unit

Write to an Mpd connection

val read_mpd_banner : t -> string

Read in an Mpd connection

val read_request_response : t -> string

Read a Mpd response to a request.

val read_command_response : t -> string

Read a Mpd response to a command.

\ No newline at end of file +Connection (libmpdclient.Mpd.Connection)

Module Mpd.Connection

Offer functions and type in order to handle connections to the mpd server at the socket level.

type t

connection type

val initialize : string -> int -> t

Create the connection, exit if the connection can not be initialized.

val hostname : t -> string

Retrieve the host's string of the initialized connection.

val port : t -> int

Retrieve the port of the connection of the initialized connection.

val close : t -> unit

Close the connection

val write : t -> string -> unit

Write to an Mpd connection

val read : t -> (string -> Protocol.mpd_response) -> string

Read in an Mpd connection

val read_mpd_banner : t -> string

Read in an Mpd connection

val read_request_response : t -> string

Read a Mpd response to a request.

val read_command_response : t -> string

Read a Mpd response to a command.

\ No newline at end of file diff --git a/docs/Mpd/Connection_lwt/index.html b/docs/Mpd/Connection_lwt/index.html index 19c64d6..c02a5fc 100644 --- a/docs/Mpd/Connection_lwt/index.html +++ b/docs/Mpd/Connection_lwt/index.html @@ -1,2 +1,2 @@ -Connection_lwt (libmpdclient.Mpd.Connection_lwt)

Module Mpd.Connection_lwt

type t

Lwt connection type for thread usage

exception Lwt_unix_exn of string

Custom exception.

val initialize : string -> int -> t Lwt.t

Create the connection in a Lwt thread, throws an exception Mpd_Lwt_unix_exn of string when an error occurs.

val hostname : t -> string Lwt.t

Get the hostname of the current connection.

val port : t -> int Lwt.t

Get the port of the current connection.

val buffer : t -> string Lwt.t

Get the buffer used by the connection.

val recvbytes : t -> Stdlib.Bytes.t Lwt.t

Read from the connection.

val write : t -> string -> int Lwt.t

Write in a Mpd connection throught a Lwt thread. It fails with an exception Mpd_Lwt_unix_exn of string.

val close : t -> unit Lwt.t

Close the connection.

\ No newline at end of file +Connection_lwt (libmpdclient.Mpd.Connection_lwt)

Module Mpd.Connection_lwt

Offer functions and type in order to handle connections to the mpd server at the socket level in Lwt thread.

type t

Lwt connection type for thread usage

exception Lwt_unix_exn of string

Custom exception.

val initialize : string -> int -> t Lwt.t

Create the connection in a Lwt thread, throws an exception Mpd_Lwt_unix_exn of string when an error occurs.

val hostname : t -> string Lwt.t

Get the hostname of the current connection.

val port : t -> int Lwt.t

Get the port of the current connection.

val buffer : t -> string Lwt.t

Get the buffer used by the connection.

val recvbytes : t -> Stdlib.Bytes.t Lwt.t

Read from the connection.

val write : t -> string -> int Lwt.t

Write in a Mpd connection throught a Lwt thread. It fails with an exception Mpd_Lwt_unix_exn of string.

val close : t -> unit Lwt.t

Close the connection.

\ No newline at end of file diff --git a/docs/Mpd/Loggin/index.html b/docs/Mpd/Loggin/index.html index 61e31e0..3a999d2 100644 --- a/docs/Mpd/Loggin/index.html +++ b/docs/Mpd/Loggin/index.html @@ -1,2 +1,2 @@ -Loggin (libmpdclient.Mpd.Loggin)

Module Mpd.Loggin

val reporter : string -> Logs.reporter
val file_exists : string -> bool
val setup : unit -> unit Lwt.t
val debuf : string -> unit Lwt.t
val err : string -> unit Lwt.t
\ No newline at end of file +Loggin (libmpdclient.Mpd.Loggin)

Module Mpd.Loggin

val reporter : string -> Logs.reporter
val file_exists : string -> bool
val setup : unit -> unit Lwt.t
val debuf : string -> unit Lwt.t
val err : string -> unit Lwt.t
\ No newline at end of file diff --git a/docs/Mpd/Music_database/index.html b/docs/Mpd/Music_database/index.html index 5da3825..a98b088 100644 --- a/docs/Mpd/Music_database/index.html +++ b/docs/Mpd/Music_database/index.html @@ -1,2 +1,30 @@ -Music_database (libmpdclient.Mpd.Music_database)

Module Mpd.Music_database

val find : Client.t -> (Tags.search_tags * string) list -> ?⁠sort:Tags.t -> ?⁠window:(int * int) -> unit -> (Song.t list, Protocol.ack_error * int * string * string) Stdlib.result

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : Client.t -> (Tags.search_tags * string) list -> Protocol.response

Find songs in the db that and adds them to current playlist. Parameters have the same meaning as for find.

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : Client.t -> (Tags.search_tags * string) list -> Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : Client.t -> string -> (Tags.search_tags * string) list -> Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
songs : int;
playtime : float;
misc : string;
}

basic type for the response of the count command.

val count : Client.t -> (Tags.t * string) list -> ?⁠group:Tags.t -> unit -> (song_count list, string) Stdlib.result

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : Client.t -> Tags.t -> (Tags.t * string) list -> (string list, string) Stdlib.result

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Client.t -> string option -> Protocol.response

Updates the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Client.t -> string option -> Protocol.response

Same as update, but also rescans unmodified files.

\ No newline at end of file +Music_database (libmpdclient.Mpd.Music_database)

Module Mpd.Music_database

Music_database module: regroups data base related commands.

val find : + Client.t -> + (Tags.search_tags * string) list -> + ?sort:Tags.t -> + ?window:(int * int) -> + unit -> + (Song.t list, Protocol.ack_error * int * string * string) Stdlib.result

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : Client.t -> (Tags.search_tags * string) list -> Protocol.response

Find songs in the db that and adds them to current playlist. Parameters have the same meaning as for find.

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : + Client.t -> + (Tags.search_tags * string) list -> + Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : + Client.t -> + string -> + (Tags.search_tags * string) list -> + Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
  1. songs : int;
  2. playtime : float;
  3. misc : string;
}

basic type for the response of the count command.

val count : + Client.t -> + (Tags.t * string) list -> + ?group:Tags.t -> + unit -> + (song_count list, string) Stdlib.result

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : + Client.t -> + Tags.t -> + (Tags.t * string) list -> + (string list, string) Stdlib.result

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Client.t -> string option -> Protocol.response

Updates the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Client.t -> string option -> Protocol.response

Same as update, but also rescans unmodified files.

\ No newline at end of file diff --git a/docs/Mpd/Music_database_lwt/index.html b/docs/Mpd/Music_database_lwt/index.html index df9a3a7..8e58837 100644 --- a/docs/Mpd/Music_database_lwt/index.html +++ b/docs/Mpd/Music_database_lwt/index.html @@ -1,2 +1,33 @@ -Music_database_lwt (libmpdclient.Mpd.Music_database_lwt)

Module Mpd.Music_database_lwt

val find : Client_lwt.t -> (Tags.search_tags * string) list -> ?⁠sort:Tags.t -> ?⁠window:(int * int) -> unit -> (Song.t list, Protocol.ack_error * int * string * string) Stdlib.result Lwt.t

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : Client_lwt.t -> (Tags.search_tags * string) list -> Protocol.response Lwt.t

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : Client_lwt.t -> (Tags.search_tags * string) list -> Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : Client_lwt.t -> string -> (Tags.search_tags * string) list -> Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
songs : int;
playtime : float;
misc : string;
}

basic type for the response of the count command.

val count : Client_lwt.t -> (Tags.t * string) list -> ?⁠group:Tags.t -> unit -> (song_count list, string) Stdlib.result Lwt.t

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : Client_lwt.t -> Tags.t -> (Tags.t * string) list -> (string list, string) Stdlib.result Lwt.t

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Client_lwt.t -> string option -> Protocol.response Lwt.t

Update the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Client_lwt.t -> string option -> Protocol.response Lwt.t

Same as update, but also rescans unmodified files.

\ No newline at end of file +Music_database_lwt (libmpdclient.Mpd.Music_database_lwt)

Module Mpd.Music_database_lwt

Music_database module with Lwt: regroups data base related commands.

val find : + Client_lwt.t -> + (Tags.search_tags * string) list -> + ?sort:Tags.t -> + ?window:(int * int) -> + unit -> + (Song.t list, Protocol.ack_error * int * string * string) Stdlib.result Lwt.t

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : + Client_lwt.t -> + (Tags.search_tags * string) list -> + Protocol.response Lwt.t

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : + Client_lwt.t -> + (Tags.search_tags * string) list -> + Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : + Client_lwt.t -> + string -> + (Tags.search_tags * string) list -> + Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
  1. songs : int;
  2. playtime : float;
  3. misc : string;
}

basic type for the response of the count command.

val count : + Client_lwt.t -> + (Tags.t * string) list -> + ?group:Tags.t -> + unit -> + (song_count list, string) Stdlib.result Lwt.t

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : + Client_lwt.t -> + Tags.t -> + (Tags.t * string) list -> + (string list, string) Stdlib.result Lwt.t

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Client_lwt.t -> string option -> Protocol.response Lwt.t

Update the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Client_lwt.t -> string option -> Protocol.response Lwt.t

Same as update, but also rescans unmodified files.

\ No newline at end of file diff --git a/docs/Mpd/Playback/index.html b/docs/Mpd/Playback/index.html index 7e49013..fef35d4 100644 --- a/docs/Mpd/Playback/index.html +++ b/docs/Mpd/Playback/index.html @@ -1,2 +1,2 @@ -Playback (libmpdclient.Mpd.Playback)

Module Mpd.Playback

val next : Client.t -> Protocol.response

Play next song in the playlist.

val previous : Client.t -> Protocol.response

Play previous song in the playlist.

val stop : Client.t -> Protocol.response

Stop playing.

val pause : Client.t -> bool -> Protocol.response

Toggle pause/resumers playing

val play : Client.t -> int -> Protocol.response

Begin playing the playlist at song number.

val playid : Client.t -> int -> Protocol.response

Begin playing the playlist at song id.

val seek : Client.t -> int -> float -> Protocol.response

Seek to the position time of entry songpos in the playlist.

val seekid : Client.t -> int -> float -> Protocol.response

Seek to the position time of song id.

val seekcur : Client.t -> float -> Protocol.response

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file +Playback (libmpdclient.Mpd.Playback)

Module Mpd.Playback

Controlling playback functions. https://www.musicpd.org/doc/protocol/playback_commands.html

Play next song in the playlist.

val previous : Client.t -> Protocol.response

Play previous song in the playlist.

Stop playing.

val pause : Client.t -> bool -> Protocol.response

Toggle pause/resumers playing

val play : Client.t -> int -> Protocol.response

Begin playing the playlist at song number.

val playid : Client.t -> int -> Protocol.response

Begin playing the playlist at song id.

val seek : Client.t -> int -> float -> Protocol.response

Seek to the position time of entry songpos in the playlist.

val seekid : Client.t -> int -> float -> Protocol.response

Seek to the position time of song id.

val seekcur : Client.t -> float -> Protocol.response

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file diff --git a/docs/Mpd/Playback_lwt/index.html b/docs/Mpd/Playback_lwt/index.html index c14fff6..3abd832 100644 --- a/docs/Mpd/Playback_lwt/index.html +++ b/docs/Mpd/Playback_lwt/index.html @@ -1,2 +1,2 @@ -Playback_lwt (libmpdclient.Mpd.Playback_lwt)

Module Mpd.Playback_lwt

val next : Client_lwt.t -> Protocol.response Lwt.t

Play next song in the playlist.

val previous : Client_lwt.t -> Protocol.response Lwt.t

Play previous song in the playlist.

val stop : Client_lwt.t -> Protocol.response Lwt.t

Stop playing.

val pause : Client_lwt.t -> bool -> Protocol.response Lwt.t

Toggle pause/resumers playing

val play : Client_lwt.t -> int -> Protocol.response Lwt.t

Begin playing the playlist at song number.

val playid : Client_lwt.t -> int -> Protocol.response Lwt.t

Begin playing the playlist at song id.

val seek : Client_lwt.t -> int -> float -> Protocol.response Lwt.t

Seek to the position time of entry songpos in the playlist.

val seekid : Client_lwt.t -> int -> float -> Protocol.response Lwt.t

Seek to the position time of song id.

val seekcur : Client_lwt.t -> float -> Protocol.response Lwt.t

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file +Playback_lwt (libmpdclient.Mpd.Playback_lwt)

Module Mpd.Playback_lwt

Controlling playback functions in Lwt thread. https://www.musicpd.org/doc/protocol/playback_commands.html

val next : Client_lwt.t -> Protocol.response Lwt.t

Play next song in the playlist.

val previous : Client_lwt.t -> Protocol.response Lwt.t

Play previous song in the playlist.

val stop : Client_lwt.t -> Protocol.response Lwt.t

Stop playing.

val pause : Client_lwt.t -> bool -> Protocol.response Lwt.t

Toggle pause/resumers playing

val play : Client_lwt.t -> int -> Protocol.response Lwt.t

Begin playing the playlist at song number.

val playid : Client_lwt.t -> int -> Protocol.response Lwt.t

Begin playing the playlist at song id.

val seek : Client_lwt.t -> int -> float -> Protocol.response Lwt.t

Seek to the position time of entry songpos in the playlist.

val seekid : Client_lwt.t -> int -> float -> Protocol.response Lwt.t

Seek to the position time of song id.

val seekcur : Client_lwt.t -> float -> Protocol.response Lwt.t

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file diff --git a/docs/Mpd/Playback_options/index.html b/docs/Mpd/Playback_options/index.html index 0af76f9..27e35a2 100644 --- a/docs/Mpd/Playback_options/index.html +++ b/docs/Mpd/Playback_options/index.html @@ -1,2 +1,2 @@ -Playback_options (libmpdclient.Mpd.Playback_options)

Module Mpd.Playback_options

val consume : Client.t -> bool -> Protocol.response

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Client.t -> int -> Protocol.response

Sets crossfading between songs.

val mixrampdb : Client.t -> int -> Protocol.response

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
| Nan
| Seconds of float

Type for the command mixrampdelay, it can be float number for seconds or nan.

val mixrampdelay : Client.t -> mixrampd_t -> Protocol.response

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Client.t -> bool -> Protocol.response

Sets random state to STATE, STATE should be true or false

val repeat : Client.t -> bool -> Protocol.response

Sets repeat state to STATE, STATE should be false or true.

val setvol : Client.t -> int -> Protocol.response

Sets volume to VOL, the range of volume is 0-100.

val single : Client.t -> bool -> Protocol.response

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
| Off
| Track
| Album
| Auto

gain_mode type for the command replay_gain_mode.

val replay_gain_mode : Client.t -> gain_mode_t -> Protocol.response

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file +Playback_options (libmpdclient.Mpd.Playback_options)

Module Mpd.Playback_options

functions that configure all the playbackoptions

val consume : Client.t -> bool -> Protocol.response

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Client.t -> int -> Protocol.response

Sets crossfading between songs.

val mixrampdb : Client.t -> int -> Protocol.response

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
  1. | Nan
  2. | Seconds of float
    (*

    Type for the command mixrampdelay, it can be float number for seconds or nan.

    *)
val mixrampdelay : Client.t -> mixrampd_t -> Protocol.response

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Client.t -> bool -> Protocol.response

Sets random state to STATE, STATE should be true or false

val repeat : Client.t -> bool -> Protocol.response

Sets repeat state to STATE, STATE should be false or true.

val setvol : Client.t -> int -> Protocol.response

Sets volume to VOL, the range of volume is 0-100.

val single : Client.t -> bool -> Protocol.response

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
  1. | Off
  2. | Track
  3. | Album
  4. | Auto
    (*

    gain_mode type for the command replay_gain_mode.

    *)
val replay_gain_mode : Client.t -> gain_mode_t -> Protocol.response

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file diff --git a/docs/Mpd/Playback_options_lwt/index.html b/docs/Mpd/Playback_options_lwt/index.html index bfa2363..be98742 100644 --- a/docs/Mpd/Playback_options_lwt/index.html +++ b/docs/Mpd/Playback_options_lwt/index.html @@ -1,2 +1,2 @@ -Playback_options_lwt (libmpdclient.Mpd.Playback_options_lwt)

Module Mpd.Playback_options_lwt

val consume : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets crossfading between songs.

val mixrampdb : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
| Nan
| Seconds of float

Type for the command mixrampdelay, it can be float for seconds or nan.

val mixrampdelay : Client_lwt.t -> mixrampd_t -> Protocol.response Lwt.t

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets random state to STATE, STATE should be true or false

val repeat : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets repeat state to STATE, STATE should be false or true.

val setvol : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets volume to VOL, the range of volume is 0-100.

val single : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
| Off
| Track
| Album
| Auto

gain_mode type for the command replay_gain_mode.

val replay_gain_mode : Client_lwt.t -> gain_mode_t -> Protocol.response Lwt.t

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file +Playback_options_lwt (libmpdclient.Mpd.Playback_options_lwt)

Module Mpd.Playback_options_lwt

functions that configure all the playbackoptions in a Lwt thread.

val consume : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets crossfading between songs.

val mixrampdb : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
  1. | Nan
  2. | Seconds of float
    (*

    Type for the command mixrampdelay, it can be float for seconds or nan.

    *)
val mixrampdelay : Client_lwt.t -> mixrampd_t -> Protocol.response Lwt.t

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets random state to STATE, STATE should be true or false

val repeat : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets repeat state to STATE, STATE should be false or true.

val setvol : Client_lwt.t -> int -> Protocol.response Lwt.t

Sets volume to VOL, the range of volume is 0-100.

val single : Client_lwt.t -> bool -> Protocol.response Lwt.t

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
  1. | Off
  2. | Track
  3. | Album
  4. | Auto
    (*

    gain_mode type for the command replay_gain_mode.

    *)
val replay_gain_mode : Client_lwt.t -> gain_mode_t -> Protocol.response Lwt.t

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file diff --git a/docs/Mpd/Protocol/index.html b/docs/Mpd/Protocol/index.html index 5543221..98bd12f 100644 --- a/docs/Mpd/Protocol/index.html +++ b/docs/Mpd/Protocol/index.html @@ -1,2 +1,2 @@ -Protocol (libmpdclient.Mpd.Protocol)

Module Mpd.Protocol

type ack_error =
| Not_list
| Arg
| Password
| Permission
| Unknown
| No_exist
| Playlist_max
| System
| Playlist_load
| Update_already
| Player_sync
| Exist

Type of error that could occur when a command is sent to the mpd server.

type response =
| Ok of string option
| Error of ack_error * int * string * string

Type of the response of the mpd server.

val error_name : ack_error -> string

Get the error name of the error type.

val str_error_to_val : string -> ack_error

Return the related type for the error returned by the server as a string.

val parse_error_response : string -> ack_error * int * string * string

Parse the error response of the mpd server into the error type.

val parse_response : string -> response

Parse the mpd server response

type mpd_response =
| Incomplete
| Complete of string * int

Type used to describe a data while reading through a socket.

val full_mpd_banner : string -> mpd_response

fetch mpd banner

val request_response : string -> mpd_response

fetch request response.

val command_response : string -> mpd_response

fetch command response.

val full_mpd_idle_event : string -> mpd_response

Get the Mpd response for an idle command.

\ No newline at end of file +Protocol (libmpdclient.Mpd.Protocol)

Module Mpd.Protocol

Define the Mpd response and error types

type ack_error =
  1. | Not_list
  2. | Arg
  3. | Password
  4. | Permission
  5. | Unknown
  6. | No_exist
  7. | Playlist_max
  8. | System
  9. | Playlist_load
  10. | Update_already
  11. | Player_sync
  12. | Exist
    (*

    Type of error that could occur when a command is sent to the mpd server.

    *)
type response =
  1. | Ok of string option
  2. | Error of ack_error * int * string * string
    (*

    Type of the response of the mpd server.

    *)
val error_name : ack_error -> string

Get the error name of the error type.

val str_error_to_val : string -> ack_error

Return the related type for the error returned by the server as a string.

val parse_error_response : string -> ack_error * int * string * string

Parse the error response of the mpd server into the error type.

val parse_response : string -> response

Parse the mpd server response

type mpd_response =
  1. | Incomplete
  2. | Complete of string * int
    (*

    Type used to describe a data while reading through a socket.

    *)
val full_mpd_banner : string -> mpd_response

fetch mpd banner

val request_response : string -> mpd_response

fetch request response.

val command_response : string -> mpd_response

fetch command response.

val full_mpd_idle_event : string -> mpd_response

Get the Mpd response for an idle command.

\ No newline at end of file diff --git a/docs/Mpd/Queue/index.html b/docs/Mpd/Queue/index.html index 4b8f266..93af687 100644 --- a/docs/Mpd/Queue/index.html +++ b/docs/Mpd/Queue/index.html @@ -1,2 +1,13 @@ -Queue (libmpdclient.Mpd.Queue)

Module Mpd.Queue

type t =
| PlaylistError of string
| Playlist of Song.t list

Playlist type.

val add : Client.t -> string -> Protocol.response

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Client.t -> string -> int -> int

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL.

val clear : Client.t -> Protocol.response

Clear the current playlist.

val delete : Client.t -> int -> ?⁠position_end:int -> unit -> Protocol.response

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Client.t -> int -> Protocol.response

Delete the song SONGID from the playlist.

val move : Client.t -> int -> ?⁠position_end:int -> int -> unit -> Protocol.response

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Client.t -> int -> int -> Protocol.response

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Client.t -> t

Get the songs in the playlist

val playlistid : Client.t -> int -> (Song.t, string) Stdlib.result

Get information for one song

val playlistfind : Client.t -> string -> string -> t

Find songs in the current playlist with strict matching.

val playlistsearch : Client.t -> string -> string -> t

Search case-insensitively for partial matches in the current playlist.

val swap : Client.t -> int -> int -> Protocol.response

Swap the positions of SONG1 and SONG2.

val shuffle : Client.t -> ?⁠range:(int * int) -> unit -> Protocol.response

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : Client.t -> int -> ?⁠range:(int * int) -> unit -> Protocol.response

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Client.t -> int -> int list -> Protocol.response

Same as prio, but address the songs with their id.

val swapid : Client.t -> int -> int -> Protocol.response

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : Client.t -> int -> ?⁠range:(float * float) -> unit -> Protocol.response

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Client.t -> int -> string -> Protocol.response

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file +Queue (libmpdclient.Mpd.Queue)

Module Mpd.Queue

Module for Mpd current playlist manipulation.

type t =
  1. | PlaylistError of string
  2. | Playlist of Song.t list
    (*

    Playlist type.

    *)
val add : Client.t -> string -> Protocol.response

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Client.t -> string -> int -> int

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL.

Clear the current playlist.

val delete : Client.t -> int -> ?position_end:int -> unit -> Protocol.response

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Client.t -> int -> Protocol.response

Delete the song SONGID from the playlist.

val move : + Client.t -> + int -> + ?position_end:int -> + int -> + unit -> + Protocol.response

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Client.t -> int -> int -> Protocol.response

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Client.t -> t

Get the songs in the playlist

val playlistid : Client.t -> int -> (Song.t, string) Stdlib.result

Get information for one song

val playlistfind : Client.t -> string -> string -> t

Find songs in the current playlist with strict matching.

val playlistsearch : Client.t -> string -> string -> t

Search case-insensitively for partial matches in the current playlist.

val swap : Client.t -> int -> int -> Protocol.response

Swap the positions of SONG1 and SONG2.

val shuffle : Client.t -> ?range:(int * int) -> unit -> Protocol.response

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : Client.t -> int -> ?range:(int * int) -> unit -> Protocol.response

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Client.t -> int -> int list -> Protocol.response

Same as prio, but address the songs with their id.

val swapid : Client.t -> int -> int -> Protocol.response

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : + Client.t -> + int -> + ?range:(float * float) -> + unit -> + Protocol.response

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Client.t -> int -> string -> Protocol.response

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file diff --git a/docs/Mpd/Queue_lwt/index.html b/docs/Mpd/Queue_lwt/index.html index 067166e..0da21ac 100644 --- a/docs/Mpd/Queue_lwt/index.html +++ b/docs/Mpd/Queue_lwt/index.html @@ -1,2 +1,27 @@ -Queue_lwt (libmpdclient.Mpd.Queue_lwt)

Module Mpd.Queue_lwt

type t =
| PlaylistError of string
| Playlist of Song.t list

Playlist type

val add : Client_lwt.t -> string -> Protocol.response Lwt.t

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Client_lwt.t -> string -> int -> int Lwt.t

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL. For example:

val clear : Client_lwt.t -> Protocol.response Lwt.t

Clear the current playlist.

val delete : Client_lwt.t -> int -> ?⁠position_end:int -> unit -> Protocol.response Lwt.t

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Client_lwt.t -> int -> Protocol.response Lwt.t

Delete the song SONGID from the playlist.

val move : Client_lwt.t -> int -> ?⁠position_end:int -> int -> unit -> Protocol.response Lwt.t

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Client_lwt.t -> t Lwt.t

Get a list of Song.s that represents all the songs in the current playlist.

val playlistid : Client_lwt.t -> int -> (Song.t, string) Stdlib.result Lwt.t

Get a list with the Song.s of the song id in the playlist

val playlistfind : Client_lwt.t -> string -> string -> t Lwt.t

Find songs in the current playlist with strict matching.

val playlistsearch : Client_lwt.t -> string -> string -> t Lwt.t

Search case-insensitively for partial matches in the current playlist.

val swap : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2.

val shuffle : Client_lwt.t -> ?⁠range:(int * int) -> unit -> Protocol.response Lwt.t

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : Client_lwt.t -> int -> ?⁠range:(int * int) -> unit -> Protocol.response Lwt.t

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Client_lwt.t -> int -> int list -> Protocol.response Lwt.t

Same as prio, but address the songs with their id.

val swapid : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : Client_lwt.t -> int -> ?⁠range:(float * float) -> unit -> Protocol.response Lwt.t

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Client_lwt.t -> int -> string -> Protocol.response Lwt.t

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file +Queue_lwt (libmpdclient.Mpd.Queue_lwt)

Module Mpd.Queue_lwt

Module for Mpd current playlist manipulation in Lwt threads.

type t =
  1. | PlaylistError of string
  2. | Playlist of Song.t list
    (*

    Playlist type

    *)
val add : Client_lwt.t -> string -> Protocol.response Lwt.t

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Client_lwt.t -> string -> int -> int Lwt.t

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL. For example:

val clear : Client_lwt.t -> Protocol.response Lwt.t

Clear the current playlist.

val delete : + Client_lwt.t -> + int -> + ?position_end:int -> + unit -> + Protocol.response Lwt.t

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Client_lwt.t -> int -> Protocol.response Lwt.t

Delete the song SONGID from the playlist.

val move : + Client_lwt.t -> + int -> + ?position_end:int -> + int -> + unit -> + Protocol.response Lwt.t

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Client_lwt.t -> t Lwt.t

Get a list of Song.s that represents all the songs in the current playlist.

val playlistid : Client_lwt.t -> int -> (Song.t, string) Stdlib.result Lwt.t

Get a list with the Song.s of the song id in the playlist

val playlistfind : Client_lwt.t -> string -> string -> t Lwt.t

Find songs in the current playlist with strict matching.

val playlistsearch : Client_lwt.t -> string -> string -> t Lwt.t

Search case-insensitively for partial matches in the current playlist.

val swap : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2.

val shuffle : + Client_lwt.t -> + ?range:(int * int) -> + unit -> + Protocol.response Lwt.t

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : + Client_lwt.t -> + int -> + ?range:(int * int) -> + unit -> + Protocol.response Lwt.t

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Client_lwt.t -> int -> int list -> Protocol.response Lwt.t

Same as prio, but address the songs with their id.

val swapid : Client_lwt.t -> int -> int -> Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : + Client_lwt.t -> + int -> + ?range:(float * float) -> + unit -> + Protocol.response Lwt.t

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Client_lwt.t -> int -> string -> Protocol.response Lwt.t

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file diff --git a/docs/Mpd/Song/index.html b/docs/Mpd/Song/index.html index 694094c..0c1d09c 100644 --- a/docs/Mpd/Song/index.html +++ b/docs/Mpd/Song/index.html @@ -1,2 +1,2 @@ -Song (libmpdclient.Mpd.Song)

Module Mpd.Song

type t

Song type

val empty : t

Empty song type

val parse : string list -> t

Parse a list of song attributes to a Song.s type

val album : t -> string
val albumsort : t -> string
val albumartist : t -> string
val albumartistsort : t -> string
val artist : t -> string
val artistsort : t -> string
val comment : t -> string
val composer : t -> string
val date : t -> string
val disc : t -> string
val duration : t -> float
val file : t -> string
val genre : t -> string
val id : t -> int
val last_modified : t -> string
val name : t -> string
val performer : t -> string
val pos : t -> int
val rate : t -> int
val time : t -> int
val title : t -> string
val track : t -> string
\ No newline at end of file +Song (libmpdclient.Mpd.Song)

Module Mpd.Song

Song module used to store and retrieve information of a song based on * mpd tags.

type t

Song type

val empty : t

Empty song type

val parse : string list -> t

Parse a list of song attributes to a Song.s type

val album : t -> string
val albumsort : t -> string
val albumartist : t -> string
val albumartistsort : t -> string
val artist : t -> string
val artistsort : t -> string
val comment : t -> string
val composer : t -> string
val date : t -> string
val disc : t -> string
val duration : t -> float
val file : t -> string
val genre : t -> string
val id : t -> int
val last_modified : t -> string
val name : t -> string
val performer : t -> string
val pos : t -> int
val rate : t -> int
val time : t -> int
val title : t -> string
val track : t -> string
\ No newline at end of file diff --git a/docs/Mpd/Status/index.html b/docs/Mpd/Status/index.html index 68cccfb..abcabfe 100644 --- a/docs/Mpd/Status/index.html +++ b/docs/Mpd/Status/index.html @@ -1,2 +1,2 @@ -Status (libmpdclient.Mpd.Status)

Module Mpd.Status

type t

Main status type that contains all the status information of the server.

type state =
| Play
| Pause
| Stop
| ErrState

Current state (playing, pause or stopped) of the mpd server.

val string_of_state : state -> string

Get the string representation of a state.

val parse : string list -> t

Parse list of strings into a Mpd Status type

val volume : t -> int

Get the volume level from a Mpd Status

val repeat : t -> bool

Find out if the player is in repeat mode

val random : t -> bool

Find out if the player is in random mode

val single : t -> bool

Find out if the player is in single mode

val consume : t -> bool

Find out if the player is in consume mode

val playlist : t -> int

Get the current playlist id

val playlistlength : t -> int

Get the current playlist length

val state : t -> state

Get the state of the player : Play / Pause / Stop

val song : t -> int

Get the song number of the current song stopped on or playing

val songid : t -> int

Get the song id of the current song stopped on or playing

val nextsong : t -> int

Get the next song number based on the current song stopped on or playing

val nextsongid : t -> int

Get the next song id based on the current song stopped on or playing

val time : t -> string

Get the total time elapsed (of current playing/paused song)

val elapsed : t -> float

Get the total time elapsed within the current song, but with higher resolution

val duration : t -> float

Returns the totatl duration of the current song in seconds

val bitrate : t -> int

Get the instantaneous bitrate in kbps

val xfade : t -> int

Get the crossfade in seconds of the current song

val mixrampdb : t -> float

Get the mixramp threshold in dB

val mixrampdelay : t -> float

Get the mixrampdelay in seconds

val audio : t -> string

Get information of the audio file of the current song (sampleRate:bits:channels)

val updating_db : t -> int

Get the job id

val error : t -> string

Get the error message if there is one

\ No newline at end of file +Status (libmpdclient.Mpd.Status)

Module Mpd.Status

Status : get informations on the current status of the Mpd server.

type t

Main status type that contains all the status information of the server.

type state =
  1. | Play
  2. | Pause
  3. | Stop
  4. | ErrState
    (*

    Current state (playing, pause or stopped) of the mpd server.

    *)
val string_of_state : state -> string

Get the string representation of a state.

val parse : string list -> t

Parse list of strings into a Mpd Status type

val volume : t -> int

Get the volume level from a Mpd Status

val repeat : t -> bool

Find out if the player is in repeat mode

val random : t -> bool

Find out if the player is in random mode

val single : t -> bool

Find out if the player is in single mode

val consume : t -> bool

Find out if the player is in consume mode

val playlist : t -> int

Get the current playlist id

val playlistlength : t -> int

Get the current playlist length

val state : t -> state

Get the state of the player : Play / Pause / Stop

val song : t -> int

Get the song number of the current song stopped on or playing

val songid : t -> int

Get the song id of the current song stopped on or playing

val nextsong : t -> int

Get the next song number based on the current song stopped on or playing

val nextsongid : t -> int

Get the next song id based on the current song stopped on or playing

val time : t -> string

Get the total time elapsed (of current playing/paused song)

val elapsed : t -> float

Get the total time elapsed within the current song, but with higher resolution

val duration : t -> float

Returns the totatl duration of the current song in seconds

val bitrate : t -> int

Get the instantaneous bitrate in kbps

val xfade : t -> int

Get the crossfade in seconds of the current song

val mixrampdb : t -> float

Get the mixramp threshold in dB

val mixrampdelay : t -> float

Get the mixrampdelay in seconds

val audio : t -> string

Get information of the audio file of the current song (sampleRate:bits:channels)

val updating_db : t -> int

Get the job id

val error : t -> string

Get the error message if there is one

\ No newline at end of file diff --git a/docs/Mpd/Stored_playlists/index.html b/docs/Mpd/Stored_playlists/index.html index 37d57d7..04b0ae1 100644 --- a/docs/Mpd/Stored_playlists/index.html +++ b/docs/Mpd/Stored_playlists/index.html @@ -1,2 +1,7 @@ -Stored_playlists (libmpdclient.Mpd.Stored_playlists)

Module Mpd.Stored_playlists

val listplaylists : Client.t -> (string list, string) Stdlib.result

Print a list of the playlist names.

val load : Client.t -> string -> ?⁠range:(int * int) -> unit -> Protocol.response

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Client.t -> string -> string -> Protocol.response

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Client.t -> string -> Protocol.response

Clear the playlist NAME.m3u.

val playlistdelete : Client.t -> string -> int -> Protocol.response

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : Client.t -> string -> int -> int -> Protocol.response

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Client.t -> string -> string -> Protocol.response

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Client.t -> string -> Protocol.response

Remove the playlist NAME.m3u from the playlist directory.

val save : Client.t -> string -> Protocol.response

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file +Stored_playlists (libmpdclient.Mpd.Stored_playlists)

Module Mpd.Stored_playlists

Stored_playlists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix).

val listplaylists : Client.t -> (string list, string) Stdlib.result

Print a list of the playlist names.

val load : + Client.t -> + string -> + ?range:(int * int) -> + unit -> + Protocol.response

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Client.t -> string -> string -> Protocol.response

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Client.t -> string -> Protocol.response

Clear the playlist NAME.m3u.

val playlistdelete : Client.t -> string -> int -> Protocol.response

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : Client.t -> string -> int -> int -> Protocol.response

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Client.t -> string -> string -> Protocol.response

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Client.t -> string -> Protocol.response

Remove the playlist NAME.m3u from the playlist directory.

val save : Client.t -> string -> Protocol.response

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file diff --git a/docs/Mpd/Stored_playlists_lwt/index.html b/docs/Mpd/Stored_playlists_lwt/index.html index 5585ac7..da1b3de 100644 --- a/docs/Mpd/Stored_playlists_lwt/index.html +++ b/docs/Mpd/Stored_playlists_lwt/index.html @@ -1,2 +1,12 @@ -Stored_playlists_lwt (libmpdclient.Mpd.Stored_playlists_lwt)

Module Mpd.Stored_playlists_lwt

val listplaylists : Client_lwt.t -> (string list, string) Stdlib.result Lwt.t

Print a list of the playlist names.

val load : Client_lwt.t -> string -> ?⁠range:(int * int) -> unit -> Protocol.response Lwt.t

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Client_lwt.t -> string -> string -> Protocol.response Lwt.t

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Client_lwt.t -> string -> Protocol.response Lwt.t

Clear the playlist NAME.m3u.

val playlistdelete : Client_lwt.t -> string -> int -> Protocol.response Lwt.t

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : Client_lwt.t -> string -> int -> int -> Protocol.response Lwt.t

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Client_lwt.t -> string -> string -> Protocol.response Lwt.t

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Client_lwt.t -> string -> Protocol.response Lwt.t

Remove the playlist NAME.m3u from the playlist directory.

val save : Client_lwt.t -> string -> Protocol.response Lwt.t

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file +Stored_playlists_lwt (libmpdclient.Mpd.Stored_playlists_lwt)

Module Mpd.Stored_playlists_lwt

LwtStoredPlaylists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix). This is module is based on Lwt.

val listplaylists : Client_lwt.t -> (string list, string) Stdlib.result Lwt.t

Print a list of the playlist names.

val load : + Client_lwt.t -> + string -> + ?range:(int * int) -> + unit -> + Protocol.response Lwt.t

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Client_lwt.t -> string -> string -> Protocol.response Lwt.t

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Client_lwt.t -> string -> Protocol.response Lwt.t

Clear the playlist NAME.m3u.

val playlistdelete : Client_lwt.t -> string -> int -> Protocol.response Lwt.t

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : + Client_lwt.t -> + string -> + int -> + int -> + Protocol.response Lwt.t

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Client_lwt.t -> string -> string -> Protocol.response Lwt.t

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Client_lwt.t -> string -> Protocol.response Lwt.t

Remove the playlist NAME.m3u from the playlist directory.

val save : Client_lwt.t -> string -> Protocol.response Lwt.t

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file diff --git a/docs/Mpd/Tags/index.html b/docs/Mpd/Tags/index.html index d6d0577..2bc8bd0 100644 --- a/docs/Mpd/Tags/index.html +++ b/docs/Mpd/Tags/index.html @@ -1,2 +1,2 @@ -Tags (libmpdclient.Mpd.Tags)

Module Mpd.Tags

type t =
| Unknown
| Artist
| Album
| Album_artist
| Title
| Track
| Name
| Genre
| Date
| Composer
| Performer
| Comment
| Disc
| Musicbrainz_artistid
| Musicbrainz_albumid
| Musicbrainz_albumartistid
| Musicbrainz_trackid
| Musicbrainz_releasetrackid
| Original_date
| Artist_sort
| Album_artist_sort
| Album_sort
| Count
val tag_to_string : t -> string
type search_tags =
| Any
| File
| Base
| Modified_since
| Mpd_tag of t
val search_tag_to_string : search_tags -> string
val build_tag_parameter : ('a -> string) -> ('a * string) list -> string
\ No newline at end of file +Tags (libmpdclient.Mpd.Tags)

Module Mpd.Tags

type t =
  1. | Unknown
  2. | Artist
  3. | Album
  4. | Album_artist
  5. | Title
  6. | Track
  7. | Name
  8. | Genre
  9. | Date
  10. | Composer
  11. | Performer
  12. | Comment
  13. | Disc
  14. | Musicbrainz_artistid
  15. | Musicbrainz_albumid
  16. | Musicbrainz_albumartistid
  17. | Musicbrainz_trackid
  18. | Musicbrainz_releasetrackid
  19. | Original_date
  20. | Artist_sort
  21. | Album_artist_sort
  22. | Album_sort
  23. | Count
val tag_to_string : t -> string
type search_tags =
  1. | Any
  2. | File
  3. | Base
  4. | Modified_since
  5. | Mpd_tag of t
val search_tag_to_string : search_tags -> string
val build_tag_parameter : ('a -> string) -> ('a * string) list -> string
\ No newline at end of file diff --git a/docs/Mpd/Utils/index.html b/docs/Mpd/Utils/index.html index 32c11bd..54fa78f 100644 --- a/docs/Mpd/Utils/index.html +++ b/docs/Mpd/Utils/index.html @@ -1,2 +1,5 @@ -Utils (libmpdclient.Mpd.Utils)

Module Mpd.Utils

val remove_trailing_new_line : string -> string

Remove new line char at the end of a string.

val remove_new_lines : string -> string

Remove all new line characters in a string.

val split_lines : string -> string list

Split multiline string into a list of strings

type item_id =
| Simple of int
| Num_on_num of int * int

Type that can save the id of an element which can be an int or two int

val num_on_num_parse : string -> item_id

Split string like "8/14" to 8 and 14, returns (-1, -1) if it fails. * is used in track and disc tab of the song data

type pair = {
key : string;
value : string;
}

Create a type used when splitting a line which has the form key: value . * This type is used by Mpd.Utils.read_key_val.

val read_key_val : string -> pair

Split a line with the form "k: v" in the value of type pair

val values_of_pairs : string list -> string list

Returns all the values of a list of strings that have the key/value form.

val bool_of_int_str : string -> bool

Get a boolean value from a string number. The string "0" is false while all * other string is true.

val read_file_paths : string -> string list

Get the file path from the ouput of the command "listplaylist name"

val read_list_playlists : string -> string list

Get playlists list from output of the command "listplaylists".

exception EMusic_database of string
val parse_count_response : string -> string option -> (int * float * string) list

Get the count list from the Mpd count command.

val print_data : string -> unit
val print_data_lwt : string -> unit Lwt.t
\ No newline at end of file +Utils (libmpdclient.Mpd.Utils)

Module Mpd.Utils

Set of helpers for the mpdlibclient library.

val remove_trailing_new_line : string -> string

Remove new line char at the end of a string.

val remove_new_lines : string -> string

Remove all new line characters in a string.

val split_lines : string -> string list

Split multiline string into a list of strings

type item_id =
  1. | Simple of int
  2. | Num_on_num of int * int

Type that can save the id of an element which can be an int or two int

val num_on_num_parse : string -> item_id

Split string like "8/14" to 8 and 14, returns (-1, -1) if it fails. * is used in track and disc tab of the song data

type pair = {
  1. key : string;
  2. value : string;
}

Create a type used when splitting a line which has the form key: value . * This type is used by Mpd.Utils.read_key_val.

val read_key_val : string -> pair

Split a line with the form "k: v" in the value of type pair

val values_of_pairs : string list -> string list

Returns all the values of a list of strings that have the key/value form.

val bool_of_int_str : string -> bool

Get a boolean value from a string number. The string "0" is false while all * other string is true.

val read_file_paths : string -> string list

Get the file path from the ouput of the command "listplaylist name"

val read_list_playlists : string -> string list

Get playlists list from output of the command "listplaylists".

exception EMusic_database of string
val parse_count_response : + string -> + string option -> + (int * float * string) list

Get the count list from the Mpd count command.

val print_data : string -> unit
val print_data_lwt : string -> unit Lwt.t
\ No newline at end of file diff --git a/docs/Mpd/index.html b/docs/Mpd/index.html index 0227ca3..6e2e67f 100644 --- a/docs/Mpd/index.html +++ b/docs/Mpd/index.html @@ -1,2 +1,2 @@ -Mpd (libmpdclient.Mpd)

Module Mpd

module Client : sig ... end
module Client_lwt : sig ... end
module Connection : sig ... end
module Connection_lwt : sig ... end
module Loggin : sig ... end
module Music_database : sig ... end
module Music_database_lwt : sig ... end
module Playback : sig ... end
module Playback_lwt : sig ... end
module Playback_options : sig ... end
module Playback_options_lwt : sig ... end
module Protocol : sig ... end
module Queue : sig ... end
module Queue_lwt : sig ... end
module Song : sig ... end
module Status : sig ... end
module Stored_playlists : sig ... end
module Stored_playlists_lwt : sig ... end
module Tags : sig ... end
module Utils : sig ... end
\ No newline at end of file +Mpd (libmpdclient.Mpd)

Module Mpd

module Client : sig ... end

Provides functions and type in order to communicate to the mpd server with commands and requests.

module Client_lwt : sig ... end

Provides functions and type in order to communicate to the mpd server with commands and requests in Lwt threads.

module Connection : sig ... end

Offer functions and type in order to handle connections to the mpd server at the socket level.

module Connection_lwt : sig ... end

Offer functions and type in order to handle connections to the mpd server at the socket level in Lwt thread.

module Loggin : sig ... end
module Music_database : sig ... end

Music_database module: regroups data base related commands.

module Music_database_lwt : sig ... end

Music_database module with Lwt: regroups data base related commands.

module Playback : sig ... end

Controlling playback functions. https://www.musicpd.org/doc/protocol/playback_commands.html

module Playback_lwt : sig ... end

Controlling playback functions in Lwt thread. https://www.musicpd.org/doc/protocol/playback_commands.html

module Playback_options : sig ... end

functions that configure all the playbackoptions

module Playback_options_lwt : sig ... end

functions that configure all the playbackoptions in a Lwt thread.

module Protocol : sig ... end

Define the Mpd response and error types

module Queue : sig ... end

Module for Mpd current playlist manipulation.

module Queue_lwt : sig ... end

Module for Mpd current playlist manipulation in Lwt threads.

module Song : sig ... end

Song module used to store and retrieve information of a song based on * mpd tags.

module Status : sig ... end

Status : get informations on the current status of the Mpd server.

module Stored_playlists : sig ... end

Stored_playlists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix).

module Stored_playlists_lwt : sig ... end

LwtStoredPlaylists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix). This is module is based on Lwt.

module Tags : sig ... end
module Utils : sig ... end

Set of helpers for the mpdlibclient library.

\ No newline at end of file diff --git a/docs/Mpd__Client/index.html b/docs/Mpd__Client/index.html deleted file mode 100644 index d21f08d..0000000 --- a/docs/Mpd__Client/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Client (libmpdclient.Mpd__Client)

Module Mpd__Client

Provides functions and type in order to communicate to the mpd server with commands and requests.

type t

Client type

val initialize : Mpd.Connection.t -> t

Initialize the client with a connection.

val send_request : t -> string -> Mpd.Protocol.response
val send_command : t -> string -> Mpd.Protocol.response
val mpd_banner : t -> string

Return the mpd banner that the server send at the first connection of the client.

val status : t -> (Mpd.Status.t, string) Stdlib.result

Create a status request and returns the status under a Mpd.Status.t type if no error occurs.

val ping : t -> Mpd.Protocol.response

Does nothing but return "OK".

val password : t -> string -> Mpd.Protocol.response

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val close : t -> unit

Close the connection to MPD. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

val tagtypes : t -> string list

Show a list of available tag types. It is an intersection of the metadata_to_use setting and this client's tag mask. About the tag mask: each client can decide to disable any number of tag types, which will be omitted from responses to this client. That is a good idea, because it makes responses smaller. The following tagtypes sub commands configure this list.

\ No newline at end of file diff --git a/docs/Mpd__Client_lwt/.dune-keep b/docs/Mpd__Client_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Client_lwt/index.html b/docs/Mpd__Client_lwt/index.html deleted file mode 100644 index 2f564f6..0000000 --- a/docs/Mpd__Client_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Client_lwt (libmpdclient.Mpd__Client_lwt)

Module Mpd__Client_lwt

Provides functions and type in order to communicate to the mpd server with commands and requests in Lwt threads.

type t

Type for a Mpd Client to be used with Lwt promises.

val initialize : Mpd.Connection_lwt.t -> t Lwt.t

Initialize the client with a connection.

val mpd_banner : t -> string Lwt.t

Return the mpd banner that the server send at the first connection of the client.

val idle : t -> (string, string) Stdlib.Pervasives.result Lwt.t

Wait for an event to occur in order to return. When a Client send this * command to the Mpd server throught its connection, the Mpd server do * not answer to any other command except the noidle command. The idea is * to first cancel the promise that has send the "idle" command with * Lwt.cancel and then send the noidle command to the Mpd server. An * example can be found in samples/mpd_lwt_client_idle_noidle.ml.

val idle_loop : t -> (string -> bool Lwt.t) -> unit Lwt.t

Loop on mpd event with the "idle" command the on_event function take the event response as argument and return true to stop or false to continue the loop

val send : t -> string -> Mpd.Protocol.response Lwt.t

Send to the mpd server a command. The response of the server is returned under the form of a Protocol.response type.

val request : t -> string -> Mpd.Protocol.response Lwt.t

Send to the mpd server a request. The response of the server is returned under the form of a Protocol.response type. A request is different from a command because a command generate an action from Mpd and returns "OK" or an error while a request does not generate an action from Mpd and returns "some data to analyse"OK or an error.

val status : t -> (Mpd.Status.t, string) Stdlib.Pervasives.result Lwt.t

Create a status request and returns the status under a Mpd.Status.s Lwt.t type.

val ping : t -> Mpd.Protocol.response Lwt.t

Does nothing but return "OK".

val password : t -> string -> Mpd.Protocol.response Lwt.t

This is used for authentication with the server. PASSWORD is simply the plaintext password.

val noidle : t -> Mpd.Protocol.response Lwt.t

This command is needed to stop listening after a Client.idle command. An example of usage can be seen in samples/mpd_lwt_client_idle_noidle.exe.

val close : t -> unit Lwt.t

Close the client. MPD will try to send the remaining output buffer before it actually closes the connection, but that cannot be guaranteed. This command will not generate a response. This function is a wrapper to the "close" command of the Mpd protocol, this means that it first send the "close" command and it close the connection at the socket level.

\ No newline at end of file diff --git a/docs/Mpd__Connection/.dune-keep b/docs/Mpd__Connection/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Connection/index.html b/docs/Mpd__Connection/index.html deleted file mode 100644 index 48b52b2..0000000 --- a/docs/Mpd__Connection/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Connection (libmpdclient.Mpd__Connection)

Module Mpd__Connection

Offer functions and type in order to handle connections to the mpd server at the socket level.

type t

connection type

val initialize : string -> int -> t

Create the connection, exit if the connection can not be initialized.

val hostname : t -> string

Retrieve the host's string of the initialized connection.

val port : t -> int

Retrieve the port of the connection of the initialized connection.

val close : t -> unit

Close the connection

val write : t -> string -> unit

Write to an Mpd connection

val read_mpd_banner : t -> string

Read in an Mpd connection

val read_request_response : t -> string

Read a Mpd response to a request.

val read_command_response : t -> string

Read a Mpd response to a command.

\ No newline at end of file diff --git a/docs/Mpd__Connection_lwt/.dune-keep b/docs/Mpd__Connection_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Connection_lwt/index.html b/docs/Mpd__Connection_lwt/index.html deleted file mode 100644 index dd3dda5..0000000 --- a/docs/Mpd__Connection_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Connection_lwt (libmpdclient.Mpd__Connection_lwt)

Module Mpd__Connection_lwt

Offer functions and type in order to handle connections to the mpd server at the socket level in Lwt thread.

type t

Lwt connection type for thread usage

exception Lwt_unix_exn of string

Custom exception.

val initialize : string -> int -> t Lwt.t

Create the connection in a Lwt thread, throws an exception Mpd_Lwt_unix_exn of string when an error occurs.

val hostname : t -> string Lwt.t

Get the hostname of the current connection.

val port : t -> int Lwt.t

Get the port of the current connection.

val buffer : t -> string Lwt.t

Get the buffer used by the connection.

val recvbytes : t -> Stdlib.Bytes.t Lwt.t

Read from the connection.

val write : t -> string -> int Lwt.t

Write in a Mpd connection throught a Lwt thread. It fails with an exception Mpd_Lwt_unix_exn of string.

val close : t -> unit Lwt.t

Close the connection.

\ No newline at end of file diff --git a/docs/Mpd__Loggin/.dune-keep b/docs/Mpd__Loggin/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Loggin/index.html b/docs/Mpd__Loggin/index.html deleted file mode 100644 index 0d20de9..0000000 --- a/docs/Mpd__Loggin/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Loggin (libmpdclient.Mpd__Loggin)

Module Mpd__Loggin

val reporter : string -> Logs.reporter
val file_exists : string -> bool
val setup : unit -> unit Lwt.t
val debuf : string -> unit Lwt.t
val err : string -> unit Lwt.t
\ No newline at end of file diff --git a/docs/Mpd__Music_database/.dune-keep b/docs/Mpd__Music_database/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Music_database/index.html b/docs/Mpd__Music_database/index.html deleted file mode 100644 index 7834ebb..0000000 --- a/docs/Mpd__Music_database/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Music_database (libmpdclient.Mpd__Music_database)

Module Mpd__Music_database

Music_database module: regroups data base related commands.

val find : Mpd.Client.t -> (Mpd.Tags.search_tags * string) list -> ?⁠sort:Mpd.Tags.t -> ?⁠window:(int * int) -> unit -> (Mpd.Song.t list, Mpd.Protocol.ack_error * int * string * string) Stdlib.result

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : Mpd.Client.t -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response

Find songs in the db that and adds them to current playlist. Parameters have the same meaning as for find.

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : Mpd.Client.t -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : Mpd.Client.t -> string -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
songs : int;
playtime : float;
misc : string;
}

basic type for the response of the count command.

val count : Mpd.Client.t -> (Mpd.Tags.t * string) list -> ?⁠group:Mpd.Tags.t -> unit -> (song_count list, string) Stdlib.result

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : Mpd.Client.t -> Mpd.Tags.t -> (Mpd.Tags.t * string) list -> (string list, string) Stdlib.result

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Mpd.Client.t -> string option -> Mpd.Protocol.response

Updates the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Mpd.Client.t -> string option -> Mpd.Protocol.response

Same as update, but also rescans unmodified files.

\ No newline at end of file diff --git a/docs/Mpd__Music_database_lwt/.dune-keep b/docs/Mpd__Music_database_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Music_database_lwt/index.html b/docs/Mpd__Music_database_lwt/index.html deleted file mode 100644 index 7bfe59e..0000000 --- a/docs/Mpd__Music_database_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Music_database_lwt (libmpdclient.Mpd__Music_database_lwt)

Module Mpd__Music_database_lwt

Music_database module with Lwt: regroups data base related commands.

val find : Mpd.Client_lwt.t -> (Mpd.Tags.search_tags * string) list -> ?⁠sort:Mpd.Tags.t -> ?⁠window:(int * int) -> unit -> (Mpd.Song.t list, Mpd.Protocol.ack_error * int * string * string) Stdlib.result Lwt.t

Find songs in the db that match exactly the a list of pairs (tag, exact_pattern). The exact_pattern is a string and the tah can be any tag supported by MPD, or one of the special parameters:

  • any checks all tag values
  • file checks the full path (relative to the music directory)
  • base restricts the search to songs in the given directory (also relative to the music directory)
  • modified-since compares the file's time stamp with the given value (ISO 8601 or UNIX time stamp)
val findadd : Mpd.Client_lwt.t -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response Lwt.t

Search for any song that contains WHAT. Parameters have the same meaning as for find, except that search is not case sensitive.

val searchadd : Mpd.Client_lwt.t -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to current playlist. Parameters have the same meaning as for findadd, except that search is not case sensitive.

val searchaddpl : Mpd.Client_lwt.t -> string -> (Mpd.Tags.search_tags * string) list -> Mpd.Protocol.response Lwt.t

Search for any song that contains WHAT in tag TYPE and adds them to the playlist named NAME. If a playlist by that name doesn't exist it is created. Parameters have the same meaning as for find, except that search is not case sensitive.

type song_count = {
songs : int;
playtime : float;
misc : string;
}

basic type for the response of the count command.

val count : Mpd.Client_lwt.t -> (Mpd.Tags.t * string) list -> ?⁠group:Mpd.Tags.t -> unit -> (song_count list, string) Stdlib.result Lwt.t

Get a count of songs with filters. For examples: count group artist will return for each artist the number of sons, the total playtime and the name of the artist in misc. Counts the number of songs and their total playtime in the db matching TAG exactly. The group keyword may be used to group the results by a tag. The following prints per-artist counts: count group artist count genre metal date 2016 group artist

val list : Mpd.Client_lwt.t -> Mpd.Tags.t -> (Mpd.Tags.t * string) list -> (string list, string) Stdlib.result Lwt.t

Get a list based on some filer. For example "list album artist "Elvis Presley"" will return a list of the album names of Elvis Presley that exists in the music database.

val update : Mpd.Client_lwt.t -> string option -> Mpd.Protocol.response Lwt.t

Update the music database: find new files, remove deleted files, update modified files. URI is a particular directory or song/file to update. If you do not specify it, everything is updated. Prints "updating_db: JOBID" where JOBID is a positive number identifying the update job. You can read the current job id in the status response.

val rescan : Mpd.Client_lwt.t -> string option -> Mpd.Protocol.response Lwt.t

Same as update, but also rescans unmodified files.

\ No newline at end of file diff --git a/docs/Mpd__Playback/.dune-keep b/docs/Mpd__Playback/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Playback/index.html b/docs/Mpd__Playback/index.html deleted file mode 100644 index 004b118..0000000 --- a/docs/Mpd__Playback/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Playback (libmpdclient.Mpd__Playback)

Module Mpd__Playback

Controlling playback functions. https://www.musicpd.org/doc/protocol/playback_commands.html

val next : Mpd.Client.t -> Mpd.Protocol.response

Play next song in the playlist.

val previous : Mpd.Client.t -> Mpd.Protocol.response

Play previous song in the playlist.

val stop : Mpd.Client.t -> Mpd.Protocol.response

Stop playing.

val pause : Mpd.Client.t -> bool -> Mpd.Protocol.response

Toggle pause/resumers playing

val play : Mpd.Client.t -> int -> Mpd.Protocol.response

Begin playing the playlist at song number.

val playid : Mpd.Client.t -> int -> Mpd.Protocol.response

Begin playing the playlist at song id.

val seek : Mpd.Client.t -> int -> float -> Mpd.Protocol.response

Seek to the position time of entry songpos in the playlist.

val seekid : Mpd.Client.t -> int -> float -> Mpd.Protocol.response

Seek to the position time of song id.

val seekcur : Mpd.Client.t -> float -> Mpd.Protocol.response

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file diff --git a/docs/Mpd__Playback_lwt/.dune-keep b/docs/Mpd__Playback_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Playback_lwt/index.html b/docs/Mpd__Playback_lwt/index.html deleted file mode 100644 index 9585f7b..0000000 --- a/docs/Mpd__Playback_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Playback_lwt (libmpdclient.Mpd__Playback_lwt)

Module Mpd__Playback_lwt

Controlling playback functions in Lwt thread. https://www.musicpd.org/doc/protocol/playback_commands.html

val next : Mpd.Client_lwt.t -> Mpd.Protocol.response Lwt.t

Play next song in the playlist.

val previous : Mpd.Client_lwt.t -> Mpd.Protocol.response Lwt.t

Play previous song in the playlist.

val stop : Mpd.Client_lwt.t -> Mpd.Protocol.response Lwt.t

Stop playing.

val pause : Mpd.Client_lwt.t -> bool -> Mpd.Protocol.response Lwt.t

Toggle pause/resumers playing

val play : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Begin playing the playlist at song number.

val playid : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Begin playing the playlist at song id.

val seek : Mpd.Client_lwt.t -> int -> float -> Mpd.Protocol.response Lwt.t

Seek to the position time of entry songpos in the playlist.

val seekid : Mpd.Client_lwt.t -> int -> float -> Mpd.Protocol.response Lwt.t

Seek to the position time of song id.

val seekcur : Mpd.Client_lwt.t -> float -> Mpd.Protocol.response Lwt.t

Seek to the position time within the current song. TODO : If prefixed by '+' or '-', then the time is relative to the current playing position

\ No newline at end of file diff --git a/docs/Mpd__Playback_options/.dune-keep b/docs/Mpd__Playback_options/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Playback_options/index.html b/docs/Mpd__Playback_options/index.html deleted file mode 100644 index b954c27..0000000 --- a/docs/Mpd__Playback_options/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Playback_options (libmpdclient.Mpd__Playback_options)

Module Mpd__Playback_options

functions that configure all the playbackoptions

val consume : Mpd.Client.t -> bool -> Mpd.Protocol.response

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Mpd.Client.t -> int -> Mpd.Protocol.response

Sets crossfading between songs.

val mixrampdb : Mpd.Client.t -> int -> Mpd.Protocol.response

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
| Nan
| Seconds of float

Type for the command mixrampdelay, it can be float number for seconds or nan.

val mixrampdelay : Mpd.Client.t -> mixrampd_t -> Mpd.Protocol.response

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Mpd.Client.t -> bool -> Mpd.Protocol.response

Sets random state to STATE, STATE should be true or false

val repeat : Mpd.Client.t -> bool -> Mpd.Protocol.response

Sets repeat state to STATE, STATE should be false or true.

val setvol : Mpd.Client.t -> int -> Mpd.Protocol.response

Sets volume to VOL, the range of volume is 0-100.

val single : Mpd.Client.t -> bool -> Mpd.Protocol.response

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
| Off
| Track
| Album
| Auto

gain_mode type for the command replay_gain_mode.

val replay_gain_mode : Mpd.Client.t -> gain_mode_t -> Mpd.Protocol.response

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file diff --git a/docs/Mpd__Playback_options_lwt/.dune-keep b/docs/Mpd__Playback_options_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Playback_options_lwt/index.html b/docs/Mpd__Playback_options_lwt/index.html deleted file mode 100644 index 56b44a7..0000000 --- a/docs/Mpd__Playback_options_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Playback_options_lwt (libmpdclient.Mpd__Playback_options_lwt)

Module Mpd__Playback_options_lwt

functions that configure all the playbackoptions in a Lwt thread.

val consume : Mpd.Client_lwt.t -> bool -> Mpd.Protocol.response Lwt.t

Sets consume state to STATE, STATE should be false or true. When consume is activated, each song played is removed from playlist.

val crossfade : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Sets crossfading between songs.

val mixrampdb : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http://sourceforge.net/projects/mixramp

type mixrampd_t =
| Nan
| Seconds of float

Type for the command mixrampdelay, it can be float for seconds or nan.

val mixrampdelay : Mpd.Client_lwt.t -> mixrampd_t -> Mpd.Protocol.response Lwt.t

Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.

val random : Mpd.Client_lwt.t -> bool -> Mpd.Protocol.response Lwt.t

Sets random state to STATE, STATE should be true or false

val repeat : Mpd.Client_lwt.t -> bool -> Mpd.Protocol.response Lwt.t

Sets repeat state to STATE, STATE should be false or true.

val setvol : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Sets volume to VOL, the range of volume is 0-100.

val single : Mpd.Client_lwt.t -> bool -> Mpd.Protocol.response Lwt.t

Sets single state to STATE, STATE should be 0 or 1. When single is activated, playback is stopped after current song, or song is repeated if the 'repeat' mode is enabled.

type gain_mode_t =
| Off
| Track
| Album
| Auto

gain_mode type for the command replay_gain_mode.

val replay_gain_mode : Mpd.Client_lwt.t -> gain_mode_t -> Mpd.Protocol.response Lwt.t

Sets the replay gain mode. One of off, track, album, auto. Changing the mode during playback may take several seconds, because the new settings does not affect the buffered data. This command triggers the options idle event.

\ No newline at end of file diff --git a/docs/Mpd__Protocol/.dune-keep b/docs/Mpd__Protocol/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Protocol/index.html b/docs/Mpd__Protocol/index.html deleted file mode 100644 index afecb59..0000000 --- a/docs/Mpd__Protocol/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Protocol (libmpdclient.Mpd__Protocol)

Module Mpd__Protocol

Define the Mpd response and error types

type ack_error =
| Not_list
| Arg
| Password
| Permission
| Unknown
| No_exist
| Playlist_max
| System
| Playlist_load
| Update_already
| Player_sync
| Exist

Type of error that could occur when a command is sent to the mpd server.

type response =
| Ok of string option
| Error of ack_error * int * string * string

Type of the response of the mpd server.

val error_name : ack_error -> string

Get the error name of the error type.

val str_error_to_val : string -> ack_error

Return the related type for the error returned by the server as a string.

val parse_error_response : string -> ack_error * int * string * string

Parse the error response of the mpd server into the error type.

val parse_response : string -> response

Parse the mpd server response

type mpd_response =
| Incomplete
| Complete of string * int

Type used to describe a data while reading through a socket.

val full_mpd_banner : string -> mpd_response

fetch mpd banner

val request_response : string -> mpd_response

fetch request response.

val command_response : string -> mpd_response

fetch command response.

val full_mpd_idle_event : string -> mpd_response

Get the Mpd response for an idle command.

\ No newline at end of file diff --git a/docs/Mpd__Queue/.dune-keep b/docs/Mpd__Queue/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Queue/index.html b/docs/Mpd__Queue/index.html deleted file mode 100644 index d3e257e..0000000 --- a/docs/Mpd__Queue/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Queue (libmpdclient.Mpd__Queue)

Module Mpd__Queue

Module for Mpd current playlist manipulation.

type t =
| PlaylistError of string
| Playlist of Mpd.Song.t list

Playlist type.

val add : Mpd.Client.t -> string -> Mpd.Protocol.response

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Mpd.Client.t -> string -> int -> int

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL.

val clear : Mpd.Client.t -> Mpd.Protocol.response

Clear the current playlist.

val delete : Mpd.Client.t -> int -> ?⁠position_end:int -> unit -> Mpd.Protocol.response

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Mpd.Client.t -> int -> Mpd.Protocol.response

Delete the song SONGID from the playlist.

val move : Mpd.Client.t -> int -> ?⁠position_end:int -> int -> unit -> Mpd.Protocol.response

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Mpd.Client.t -> int -> int -> Mpd.Protocol.response

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Mpd.Client.t -> t

Get the songs in the playlist

val playlistid : Mpd.Client.t -> int -> (Mpd.Song.t, string) Stdlib.result

Get information for one song

val playlistfind : Mpd.Client.t -> string -> string -> t

Find songs in the current playlist with strict matching.

val playlistsearch : Mpd.Client.t -> string -> string -> t

Search case-insensitively for partial matches in the current playlist.

val swap : Mpd.Client.t -> int -> int -> Mpd.Protocol.response

Swap the positions of SONG1 and SONG2.

val shuffle : Mpd.Client.t -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : Mpd.Client.t -> int -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Mpd.Client.t -> int -> int list -> Mpd.Protocol.response

Same as prio, but address the songs with their id.

val swapid : Mpd.Client.t -> int -> int -> Mpd.Protocol.response

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : Mpd.Client.t -> int -> ?⁠range:(float * float) -> unit -> Mpd.Protocol.response

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Mpd.Client.t -> int -> string -> Mpd.Protocol.response

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file diff --git a/docs/Mpd__Queue_lwt/.dune-keep b/docs/Mpd__Queue_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Queue_lwt/index.html b/docs/Mpd__Queue_lwt/index.html deleted file mode 100644 index 5cf5380..0000000 --- a/docs/Mpd__Queue_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Queue_lwt (libmpdclient.Mpd__Queue_lwt)

Module Mpd__Queue_lwt

Module for Mpd current playlist manipulation in Lwt threads.

type t =
| PlaylistError of string
| Playlist of Mpd.Song.t list

Playlist type

val add : Mpd.Client_lwt.t -> string -> Mpd.Protocol.response Lwt.t

Add the file URI to the playlist (directories add recursively). URI can also be a single file.

val addid : Mpd.Client_lwt.t -> string -> int -> int Lwt.t

Add a song to the playlist (non-recursive) and returns the song id. URI is always a single file or URL. For example:

val clear : Mpd.Client_lwt.t -> Mpd.Protocol.response Lwt.t

Clear the current playlist.

val delete : Mpd.Client_lwt.t -> int -> ?⁠position_end:int -> unit -> Mpd.Protocol.response Lwt.t

Delete a song or a set of songs from the playlist. The song or the range of songs are identified by the position in the playlist.

val deleteid : Mpd.Client_lwt.t -> int -> Mpd.Protocol.response Lwt.t

Delete the song SONGID from the playlist.

val move : Mpd.Client_lwt.t -> int -> ?⁠position_end:int -> int -> unit -> Mpd.Protocol.response Lwt.t

Move the song at FROM or range of songs at START:END to TO in the playlist.

val moveid : Mpd.Client_lwt.t -> int -> int -> Mpd.Protocol.response Lwt.t

Move the song with FROM (songid) to TO (playlist index) in the playlist. If TO is negative, it is relative to the current song in the playlist (if there is one).

val playlist : Mpd.Client_lwt.t -> t Lwt.t

Get a list of Song.s that represents all the songs in the current playlist.

val playlistid : Mpd.Client_lwt.t -> int -> (Mpd.Song.t, string) Stdlib.result Lwt.t

Get a list with the Song.s of the song id in the playlist

val playlistfind : Mpd.Client_lwt.t -> string -> string -> t Lwt.t

Find songs in the current playlist with strict matching.

val playlistsearch : Mpd.Client_lwt.t -> string -> string -> t Lwt.t

Search case-insensitively for partial matches in the current playlist.

val swap : Mpd.Client_lwt.t -> int -> int -> Mpd.Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2.

val shuffle : Mpd.Client_lwt.t -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response Lwt.t

Shuffle the current playlist. START:END is optional and specifies a range of songs.

val prio : Mpd.Client_lwt.t -> int -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response Lwt.t

Set the priority of the specified songs. A higher priority means that it will be played first when "random" mode is enabled. A priority is an integer between 0 and 255. The default priority of new songs is 0.

val prioid : Mpd.Client_lwt.t -> int -> int list -> Mpd.Protocol.response Lwt.t

Same as prio, but address the songs with their id.

val swapid : Mpd.Client_lwt.t -> int -> int -> Mpd.Protocol.response Lwt.t

Swap the positions of SONG1 and SONG2 (both song ids).

val rangeid : Mpd.Client_lwt.t -> int -> ?⁠range:(float * float) -> unit -> Mpd.Protocol.response Lwt.t

Specify the portion of the song that shall be played. START and END are offsets in seconds (fractional seconds allowed); both are optional. Omitting both (i.e. sending just ":") means "remove the range, play everything". A song that is currently playing cannot be manipulated this way.

val cleartagid : Mpd.Client_lwt.t -> int -> string -> Mpd.Protocol.response Lwt.t

Remove tags from the specified song. If TAG is not specified, then all tag values will be removed. Editing song tags is only possible for remote songs.

\ No newline at end of file diff --git a/docs/Mpd__Song/.dune-keep b/docs/Mpd__Song/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Song/index.html b/docs/Mpd__Song/index.html deleted file mode 100644 index 82c8d3e..0000000 --- a/docs/Mpd__Song/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Song (libmpdclient.Mpd__Song)

Module Mpd__Song

Song module used to store and retrieve information of a song based on * mpd tags.

type t

Song type

val empty : t

Empty song type

val parse : string list -> t

Parse a list of song attributes to a Song.s type

val album : t -> string
val albumsort : t -> string
val albumartist : t -> string
val albumartistsort : t -> string
val artist : t -> string
val artistsort : t -> string
val comment : t -> string
val composer : t -> string
val date : t -> string
val disc : t -> string
val duration : t -> float
val file : t -> string
val genre : t -> string
val id : t -> int
val last_modified : t -> string
val name : t -> string
val performer : t -> string
val pos : t -> int
val rate : t -> int
val time : t -> int
val title : t -> string
val track : t -> string
\ No newline at end of file diff --git a/docs/Mpd__Status/.dune-keep b/docs/Mpd__Status/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Status/index.html b/docs/Mpd__Status/index.html deleted file mode 100644 index 10407cb..0000000 --- a/docs/Mpd__Status/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Status (libmpdclient.Mpd__Status)

Module Mpd__Status

Status : get informations on the current status of the Mpd server.

type t

Main status type that contains all the status information of the server.

type state =
| Play
| Pause
| Stop
| ErrState

Current state (playing, pause or stopped) of the mpd server.

val string_of_state : state -> string

Get the string representation of a state.

val parse : string list -> t

Parse list of strings into a Mpd Status type

val volume : t -> int

Get the volume level from a Mpd Status

val repeat : t -> bool

Find out if the player is in repeat mode

val random : t -> bool

Find out if the player is in random mode

val single : t -> bool

Find out if the player is in single mode

val consume : t -> bool

Find out if the player is in consume mode

val playlist : t -> int

Get the current playlist id

val playlistlength : t -> int

Get the current playlist length

val state : t -> state

Get the state of the player : Play / Pause / Stop

val song : t -> int

Get the song number of the current song stopped on or playing

val songid : t -> int

Get the song id of the current song stopped on or playing

val nextsong : t -> int

Get the next song number based on the current song stopped on or playing

val nextsongid : t -> int

Get the next song id based on the current song stopped on or playing

val time : t -> string

Get the total time elapsed (of current playing/paused song)

val elapsed : t -> float

Get the total time elapsed within the current song, but with higher resolution

val duration : t -> float

Returns the totatl duration of the current song in seconds

val bitrate : t -> int

Get the instantaneous bitrate in kbps

val xfade : t -> int

Get the crossfade in seconds of the current song

val mixrampdb : t -> float

Get the mixramp threshold in dB

val mixrampdelay : t -> float

Get the mixrampdelay in seconds

val audio : t -> string

Get information of the audio file of the current song (sampleRate:bits:channels)

val updating_db : t -> int

Get the job id

val error : t -> string

Get the error message if there is one

\ No newline at end of file diff --git a/docs/Mpd__Stored_playlists/.dune-keep b/docs/Mpd__Stored_playlists/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Stored_playlists/index.html b/docs/Mpd__Stored_playlists/index.html deleted file mode 100644 index 0516863..0000000 --- a/docs/Mpd__Stored_playlists/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Stored_playlists (libmpdclient.Mpd__Stored_playlists)

Module Mpd__Stored_playlists

Stored_playlists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix).

val listplaylists : Mpd.Client.t -> (string list, string) Stdlib.result

Print a list of the playlist names.

val load : Mpd.Client.t -> string -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Mpd.Client.t -> string -> string -> Mpd.Protocol.response

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Mpd.Client.t -> string -> Mpd.Protocol.response

Clear the playlist NAME.m3u.

val playlistdelete : Mpd.Client.t -> string -> int -> Mpd.Protocol.response

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : Mpd.Client.t -> string -> int -> int -> Mpd.Protocol.response

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Mpd.Client.t -> string -> string -> Mpd.Protocol.response

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Mpd.Client.t -> string -> Mpd.Protocol.response

Remove the playlist NAME.m3u from the playlist directory.

val save : Mpd.Client.t -> string -> Mpd.Protocol.response

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file diff --git a/docs/Mpd__Stored_playlists_lwt/.dune-keep b/docs/Mpd__Stored_playlists_lwt/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Stored_playlists_lwt/index.html b/docs/Mpd__Stored_playlists_lwt/index.html deleted file mode 100644 index 639b775..0000000 --- a/docs/Mpd__Stored_playlists_lwt/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Stored_playlists_lwt (libmpdclient.Mpd__Stored_playlists_lwt)

Module Mpd__Stored_playlists_lwt

LwtStoredPlaylists : Playlists are stored inside the configured playlist directory. They are addressed with their file name (without the directory and without the .m3u suffix). This is module is based on Lwt.

val listplaylists : Mpd.Client_lwt.t -> (string list, string) Stdlib.result Lwt.t

Print a list of the playlist names.

val load : Mpd.Client_lwt.t -> string -> ?⁠range:(int * int) -> unit -> Mpd.Protocol.response Lwt.t

Load the playlist into the current queue. Playlist plugins are supported. A range may be specified to load only a part of the playlist.

val playlistadd : Mpd.Client_lwt.t -> string -> string -> Mpd.Protocol.response Lwt.t

Add URI to the playlist NAME.m3u. NAME.m3u will be created if it does not exist.

val playlistclear : Mpd.Client_lwt.t -> string -> Mpd.Protocol.response Lwt.t

Clear the playlist NAME.m3u.

val playlistdelete : Mpd.Client_lwt.t -> string -> int -> Mpd.Protocol.response Lwt.t

Delete SONGPOS from the playlist NAME.m3u.

val playlistmove : Mpd.Client_lwt.t -> string -> int -> int -> Mpd.Protocol.response Lwt.t

Move the song at position FROM in the playlist NAME.m3u to the position TO.

val rename : Mpd.Client_lwt.t -> string -> string -> Mpd.Protocol.response Lwt.t

Rename the playlist NAME.m3u to NEW_NAME.m3u.

val rm : Mpd.Client_lwt.t -> string -> Mpd.Protocol.response Lwt.t

Remove the playlist NAME.m3u from the playlist directory.

val save : Mpd.Client_lwt.t -> string -> Mpd.Protocol.response Lwt.t

Save the current playlist to NAME.m3u in the playlist directory.

\ No newline at end of file diff --git a/docs/Mpd__Tags/.dune-keep b/docs/Mpd__Tags/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Tags/index.html b/docs/Mpd__Tags/index.html deleted file mode 100644 index 167aeeb..0000000 --- a/docs/Mpd__Tags/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Tags (libmpdclient.Mpd__Tags)

Module Mpd__Tags

type t =
| Unknown
| Artist
| Album
| Album_artist
| Title
| Track
| Name
| Genre
| Date
| Composer
| Performer
| Comment
| Disc
| Musicbrainz_artistid
| Musicbrainz_albumid
| Musicbrainz_albumartistid
| Musicbrainz_trackid
| Musicbrainz_releasetrackid
| Original_date
| Artist_sort
| Album_artist_sort
| Album_sort
| Count
val tag_to_string : t -> string
type search_tags =
| Any
| File
| Base
| Modified_since
| Mpd_tag of t
val search_tag_to_string : search_tags -> string
val build_tag_parameter : ('a -> string) -> ('a * string) list -> string
\ No newline at end of file diff --git a/docs/Mpd__Utils/.dune-keep b/docs/Mpd__Utils/.dune-keep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/Mpd__Utils/index.html b/docs/Mpd__Utils/index.html deleted file mode 100644 index b432f2b..0000000 --- a/docs/Mpd__Utils/index.html +++ /dev/null @@ -1,2 +0,0 @@ - -Mpd__Utils (libmpdclient.Mpd__Utils)

Module Mpd__Utils

Set of helpers for the mpdlibclient library.

val remove_trailing_new_line : string -> string

Remove new line char at the end of a string.

val remove_new_lines : string -> string

Remove all new line characters in a string.

val split_lines : string -> string list

Split multiline string into a list of strings

type item_id =
| Simple of int
| Num_on_num of int * int

Type that can save the id of an element which can be an int or two int

val num_on_num_parse : string -> item_id

Split string like "8/14" to 8 and 14, returns (-1, -1) if it fails. * is used in track and disc tab of the song data

type pair = {
key : string;
value : string;
}

Create a type used when splitting a line which has the form key: value . * This type is used by Mpd.Utils.read_key_val.

val read_key_val : string -> pair

Split a line with the form "k: v" in the value of type pair

val values_of_pairs : string list -> string list

Returns all the values of a list of strings that have the key/value form.

val bool_of_int_str : string -> bool

Get a boolean value from a string number. The string "0" is false while all * other string is true.

val read_file_paths : string -> string list

Get the file path from the ouput of the command "listplaylist name"

val read_list_playlists : string -> string list

Get playlists list from output of the command "listplaylists".

exception EMusic_database of string
val parse_count_response : string -> string option -> (int * float * string) list

Get the count list from the Mpd count command.

val print_data : string -> unit
val print_data_lwt : string -> unit Lwt.t
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index d53537e..773aab0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,2 +1,2 @@ -index (libmpdclient.index)

Library libmpdclient

The entry point of this library is the module: Mpd.

\ No newline at end of file +index (libmpdclient.index)

libmpdclient index

Library libmpdclient

The entry point of this library is the module: Mpd.

\ No newline at end of file diff --git a/docs/odoc.css b/docs/odoc.css index 3d60b5d..8b0ed5a 100644 --- a/docs/odoc.css +++ b/docs/odoc.css @@ -1,27 +1,134 @@ @charset "UTF-8"; -/* Copyright (c) 2016 Daniel C. Bünzli. All rights reserved. +/* Copyright (c) 2016 The odoc contributors. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - odoc 1.3.0 */ + odoc 2.2.0 */ /* Fonts */ @import url('https://fonts.googleapis.com/css?family=Fira+Mono:400,500'); @import url('https://fonts.googleapis.com/css?family=Noticia+Text:400,400i,700'); @import url('https://fonts.googleapis.com/css?family=Fira+Sans:400,400i,500,500i,600,600i,700,700i'); +:root, +.light:root { + --main-background: #FFFFFF; + + --color: #333333; + --link-color: #2C94BD; + --anchor-hover: #555; + --anchor-color: #d5d5d5; + --xref-shadow: #cc6666; + --header-shadow: #ddd; + --by-name-version-color: #aaa; + --by-name-nav-link-color: #222; + --target-background: rgba(187, 239, 253, 0.3); + --target-shadow: rgba(187, 239, 253, 0.8); + --pre-border-color: #eee; + --code-background: #f6f8fa; + + --li-code-background: #f6f8fa; + --li-code-color: #0d2b3e; + --toc-color: #1F2D3D; + --toc-before-color: #777; + --toc-background: #f6f8fa; + --toc-list-border: #ccc; + + --spec-summary-border-color: #5c9cf5; + --spec-summary-background: var(--code-background); + --spec-summary-hover-background: #ebeff2; + --spec-details-after-background: rgba(0, 4, 15, 0.05); + --spec-details-after-shadow: rgba(204, 204, 204, 0.53); +} + +.dark:root { + --main-background: #202020; + --code-background: #222; + --line-numbers-background: rgba(0, 0, 0, 0.125); + --navbar-background: #202020; + + --color: #bebebe; + --dirname-color: #666; + --underline-color: #444; + --visited-color: #002800; + --visited-number-color: #252; + --unvisited-color: #380000; + --unvisited-number-color: #622; + --somevisited-color: #303000; + --highlight-color: #303e3f; + --line-number-color: rgba(230, 230, 230, 0.3); + --unvisited-margin-color: #622; + --border: #333; + --navbar-border: #333; + --code-color: #ccc; + + --li-code-background: #373737; + --li-code-color: #999; + --toc-color: #777; + --toc-background: #252525; + + --hljs-link: #999; + --hljs-keyword: #cda869; + --hljs-regexp: #f9ee98; + --hljs-title: #dcdcaa; + --hljs-type: #ac885b; + --hljs-meta: #82aaff; + --hljs-variable: #cf6a4c; +} + +@media (prefers-color-scheme: dark) { + :root { + --main-background: #202020; + --code-background: #333; + --line-numbers-background: rgba(0, 0, 0, 0.125); + --navbar-background: #202020; + + --meter-unvisited-color: #622; + --meter-visited-color: #252; + --meter-separator-color: black; + + --color: #bebebe; + --dirname-color: #666; + --underline-color: #444; + --visited-color: #002800; + --visited-number-color: #252; + --unvisited-color: #380000; + --unvisited-number-color: #622; + --somevisited-color: #303000; + --highlight-color: #303e3f; + --line-number-color: rgba(230, 230, 230, 0.3); + --unvisited-margin-color: #622; + --border: #333; + --navbar-border: #333; + --code-color: #ccc; + --by-name-nav-link-color: var(--color); + + --li-code-background: #373737; + --li-code-color: #999; + --toc-color: #777; + --toc-before-color: #777; + --toc-background: #252525; + --toc-list-border: #ccc; + --spec-summary-hover-background: #ebeff2; + --spec-details-after-background: rgba(0, 4, 15, 0.05); + --spec-details-after-shadow: rgba(204, 204, 204, 0.53); + + --hljs-link: #999; + --hljs-keyword: #cda869; + --hljs-regexp: #f9ee98; + --hljs-title: #dcdcaa; + --hljs-type: #ac885b; + --hljs-meta: #82aaff; + --hljs-variable: #cf6a4c; + } +} /* Reset a few things. */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { - margin: 0; padding: 0; border: 0; - font-size: inherit; font: inherit; - line-height: inherit; vertical-align: baseline; - text-align: inherit; - color: inherit; - background: transparent; + } table { @@ -38,14 +145,14 @@ html { } body { - font-family: "Fira Sans", Helvetica, Arial, sans-serif; text-align: left; - color: #333; background: #FFFFFF; + color: var(--color); + background-color: var(--main-background); } -.content { - max-width: 90ex; +body { + max-width: 100ex; margin-left: calc(10vw + 20ex); margin-right: 4ex; margin-top: 20px; @@ -54,24 +161,32 @@ body { line-height: 1.5; } -.content>header { +header { margin-bottom: 30px; } -.content>header nav { +nav { font-family: "Fira Sans", Helvetica, Arial, sans-serif; } /* Basic markup elements */ b, strong { - font-weight: 500; + font-weight: bold; +} + +i { + font-style: italic; } -i, em { +em, i em.odd{ font-style: italic; } +em.odd, i em { + font-style: normal; +} + sup { vertical-align: super; } @@ -86,15 +201,6 @@ sup, sub { margin-left: 0.2ex; } -pre { - margin-top: 0.8em; - margin-bottom: 1.2em; -} - -p, ul, ol { - margin-top: 0.5em; - margin-bottom: 1em; -} ul, ol { list-style-position: outside } @@ -129,32 +235,32 @@ li>*:first-child { a { text-decoration: none; - color: #2C5CBD; + color: var(--link-color); } a:hover { - box-shadow: 0 1px 0 0 #2C5CBD; + box-shadow: 0 1px 0 0 var(--link-color); } /* Linked highlight */ *:target { - background-color: rgba(187,239,253,0.3) !important; - box-shadow: 0 0px 0 1px rgba(187,239,253,0.8) !important; + background-color: var(--target-background) !important; + box-shadow: 0 0px 0 1px var(--target-shadow) !important; border-radius: 1px; } -*:hover>a.anchor { +*:hover > a.anchor { visibility: visible; } a.anchor:before { - content: "#" + content: "#"; } a.anchor:hover { box-shadow: none; text-decoration: none; - color: #555; + color: var(--anchor-hover); } a.anchor { @@ -168,7 +274,7 @@ a.anchor { padding-right: 0.4em; padding-left: 0.4em; /* To remain selectable */ - color: #d5d5d5; + color: var(--anchor-color); } .spec > a.anchor { @@ -177,10 +283,10 @@ a.anchor { } .xref-unresolved { - color: #2C5CBD; + color: #2C94BD; } .xref-unresolved:hover { - box-shadow: 0 1px 0 0 #CC6666; + box-shadow: 0 1px 0 0 var(--xref-shadow); } /* Section and document divisions. @@ -190,7 +296,6 @@ a.anchor { h1, h2, h3, h4, h5, h6, .h7, .h8, .h9, .h10 { font-family: "Fira Sans", Helvetica, Arial, sans-serif; font-weight: 400; - margin: 0.5em 0 0.5em 0; padding-top: 0.1em; line-height: 1.2; overflow-wrap: break-word; @@ -199,20 +304,19 @@ h1, h2, h3, h4, h5, h6, .h7, .h8, .h9, .h10 { h1 { font-weight: 500; font-size: 2.441em; - margin-top: 1.214em; } -h2 { +h1 { font-weight: 500; font-size: 1.953em; - box-shadow: 0 1px 0 0 #ddd; + box-shadow: 0 1px 0 0 var(--header-shadow); } -h3 { +h2 { font-size: 1.563em; } -h4 { +h3 { font-size: 1.25em; } @@ -235,34 +339,60 @@ h3 code, h3 tt { font-weight: inherit; } -h4 code, h4 tt { +h3 code, h3 tt { font-size: inherit; font-weight: inherit; } +h4 { + font-size: 1.12em; +} + +/* Comment delimiters, hidden but accessible to screen readers and + selected for copy/pasting */ + +/* Taken from bootstrap */ +/* See also https://stackoverflow.com/a/27769435/4220738 */ +.comment-delim { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} + /* Preformatted and code */ tt, code, pre { - font-family: "Fira Code", "Fira Mono", courier; + font-family: "Fira Mono", courier; font-weight: 400; } pre { padding: 0.1em; - border: 1px solid #eee; + border: 1px solid var(--pre-border-color); border-radius: 5px; overflow-x: auto; } -p code, li code { - background-color: #f6f8fa; - color: #0d2b3e; +p code, +li code { + background-color: var(--li-code-background); + color: var(--li-code-color); border-radius: 3px; padding: 0 0.3ex; } p a > code { - color: #2C5CBD; + color: var(--link-color); +} + +code { + white-space: pre-wrap; } /* Code blocks (e.g. Examples) */ @@ -274,64 +404,59 @@ pre code { /* Code lexemes */ .keyword { - font-weight: 700; + font-weight: 500; } +.arrow { white-space: nowrap } + /* Module member specification */ -.spec:not(.include), .spec.include details summary { - background-color: #f6f8fa; +.spec { + background-color: var(--spec-summary-background); border-radius: 3px; - border-left: 4px solid #5c9cf5; + border-left: 4px solid var(--spec-summary-border-color); border-right: 5px solid transparent; padding: 0.35em 0.5em; } -.spec.include details summary:hover { - background-color: #ebeff2; +li:not(:last-child) > .def-doc { + margin-bottom: 15px; } -dl, div.spec, .doc, aside { - margin-bottom: 20px; +/* Spacing between items */ +div.odoc-spec,.odoc-include { + margin-bottom: 2em; } -/* Indent the second line in multiline spec definitions. */ -.spec:not(.type) > code { - display: block; - padding-left: 4ex; - text-indent: -4ex; +.spec.type .variant p, .spec.type .record p { + margin: 5px; } -.spec.exception > code { - display: inline-block; +.spec.type .variant, .spec.type .record { + margin-left: 2ch; + list-style: none; + display: flex; + flex-wrap: wrap; + row-gap: 4px; } -dl > dd { - padding: 0.5em; +.spec.type .record > code, .spec.type .variant > code { + min-width: 40%; } -dd> :first-child { +.spec.type > ol { margin-top: 0; -} - -dl:last-child, dd> :last-child, aside:last-child, article:last-child { margin-bottom: 0; } -dt+dt { - margin-top: 15px; -} - -section+section, section > header + dl { - margin-top: 25px; -} - -.spec.type .variant { - margin-left: 2ch; -} -.spec.type .variant p { - margin: 0; - font-style: italic; +.spec.type .record > .def-doc, .spec.type .variant > .def-doc { + min-width:50%; + padding: 0.25em 0.5em; + margin-left: 10%; + border-radius: 3px; + flex-grow:1; + background: var(--main-background); + box-shadow: 2px 2px 4px lightgrey; } div.def { @@ -340,27 +465,21 @@ div.def { padding-left: 2ex; } -div.def+div.doc { - margin-left: 1ex; - margin-top: 2.5px -} - -div.doc>*:first-child { +div.def-doc>*:first-child { margin-top: 0; } -/* The elements other than heading should be wrapped in