mpvrc/mrc/index.html
2025-05-22 18:44:44 +00:00

33 lines
No EOL
8.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="MRC A library for interacting with the MPV media player using its JSON IPC (Inter-Process Communication) protocol."><title>mrc - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-916cea96.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="mrc" data-themes="" data-resource-suffix="" data-rustdoc-version="1.87.0 (17067e9ac 2025-05-09)" data-channel="1.87.0" data-search-js="search-e7298875.js" data-settings-js="settings-d72f25bb.js" ><script src="../static.files/storage-82c7156e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-fb8c74a8.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../mrc/index.html">mrc</a><span class="version">0.1.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#features" title="Features">Features</a></li><li><a href="#example-usage" title="Example Usage">Example Usage</a></li><li><a href="#constants" title="Constants">Constants</a><ul><li><a href="#socket_path" title="`SOCKET_PATH`"><code>SOCKET_PATH</code></a></li></ul></li><li><a href="#functions" title="Functions">Functions</a></li></ul><h3><a href="#enums">Crate Items</a></h3><ul class="block"><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#constants-1" title="Constants">Constants</a></li><li><a href="#functions-1" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>mrc</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/mrc/lib.rs.html#1-357">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>MRC
A library for interacting with the MPV media player using its JSON IPC (Inter-Process Communication) protocol.</p>
<p>This crate provides a set of utilities to communicate with MPVs IPC socket, enabling you to send commands
and retrieve responses in a structured format.</p>
<h3 id="features"><a class="doc-anchor" href="#features">§</a>Features</h3>
<ul>
<li>Send commands to MPVs IPC socket</li>
<li>Retrieve responses in JSON format</li>
<li>Supports common MPV commands like <code>set_property</code>, <code>seek</code>, and <code>playlist-next</code></li>
<li>Flexible socket path configuration</li>
</ul>
<h3 id="example-usage"><a class="doc-anchor" href="#example-usage">§</a>Example Usage</h3>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::json;
<span class="kw">use </span>tokio;
<span class="kw">use </span>mrc::{send_ipc_command, playlist_next, set_property};
<span class="attr">#[tokio::main]
</span><span class="kw">async fn </span>main() {
<span class="kw">let </span>result = playlist_next(<span class="prelude-val">None</span>).<span class="kw">await</span>;
<span class="kw">match </span>result {
<span class="prelude-val">Ok</span>(response) =&gt; <span class="macro">println!</span>(<span class="string">"Playlist moved to next: {:?}"</span>, response),
<span class="prelude-val">Err</span>(err) =&gt; <span class="macro">eprintln!</span>(<span class="string">"Error: {:?}"</span>, err),
}
<span class="kw">let </span>property_result = set_property(<span class="string">"volume"</span>, <span class="kw-2">&amp;</span><span class="macro">json!</span>(<span class="number">50</span>), <span class="prelude-val">None</span>).<span class="kw">await</span>;
<span class="kw">match </span>property_result {
<span class="prelude-val">Ok</span>(response) =&gt; <span class="macro">println!</span>(<span class="string">"Volume set: {:?}"</span>, response),
<span class="prelude-val">Err</span>(err) =&gt; <span class="macro">eprintln!</span>(<span class="string">"Error: {:?}"</span>, err),
}
}</code></pre></div>
<h3 id="constants"><a class="doc-anchor" href="#constants">§</a>Constants</h3><h4 id="socket_path"><a class="doc-anchor" href="#socket_path">§</a><code>SOCKET_PATH</code></h4>
<p>Default path for the MPV IPC socket: <code>/tmp/mpvsocket</code></p>
<h3 id="functions"><a class="doc-anchor" href="#functions">§</a>Functions</h3></div></details><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.MpvCommand.html" title="enum mrc::MpvCommand">MpvCommand</a></dt><dd>Represents common MPV commands.</dd></dl><h2 id="constants-1" class="section-header">Constants<a href="#constants-1" class="anchor">§</a></h2><dl class="item-table"><dt><a class="constant" href="constant.SOCKET_PATH.html" title="constant mrc::SOCKET_PATH">SOCKET_<wbr>PATH</a></dt></dl><h2 id="functions-1" class="section-header">Functions<a href="#functions-1" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.get_property.html" title="fn mrc::get_property">get_<wbr>property</a></dt><dd>Sends the <code>get_property</code> command to retrieve a property value from MPV.</dd><dt><a class="fn" href="fn.loadfile.html" title="fn mrc::loadfile">loadfile</a></dt><dd>Sends the <code>loadfile</code> command to load a file into MPV.</dd><dt><a class="fn" href="fn.playlist_clear.html" title="fn mrc::playlist_clear">playlist_<wbr>clear</a></dt><dd>Sends the <code>playlist-clear</code> command to clear the playlist.</dd><dt><a class="fn" href="fn.playlist_move.html" title="fn mrc::playlist_move">playlist_<wbr>move</a></dt><dd>Sends the <code>playlist-move</code> command to move a playlist item from one index to another.</dd><dt><a class="fn" href="fn.playlist_next.html" title="fn mrc::playlist_next">playlist_<wbr>next</a></dt><dd>Sends the <code>playlist-next</code> command to move to the next playlist item.</dd><dt><a class="fn" href="fn.playlist_prev.html" title="fn mrc::playlist_prev">playlist_<wbr>prev</a></dt><dd>Sends the <code>playlist-prev</code> command to move to the previous playlist item.</dd><dt><a class="fn" href="fn.playlist_remove.html" title="fn mrc::playlist_remove">playlist_<wbr>remove</a></dt><dd>Sends the <code>playlist-remove</code> command to remove an item from the playlist.</dd><dt><a class="fn" href="fn.quit.html" title="fn mrc::quit">quit</a></dt><dd>Sends the <code>quit</code> command to terminate MPV.</dd><dt><a class="fn" href="fn.seek.html" title="fn mrc::seek">seek</a></dt><dd>Sends the <code>seek</code> command to seek the media playback by a given number of seconds.</dd><dt><a class="fn" href="fn.send_ipc_command.html" title="fn mrc::send_ipc_command">send_<wbr>ipc_<wbr>command</a></dt><dd>Sends a generic IPC command to the specified socket and returns the parsed response data.</dd><dt><a class="fn" href="fn.set_property.html" title="fn mrc::set_property">set_<wbr>property</a></dt><dd>Sends the <code>set_property</code> command to MPV to change a property value.</dd></dl></section></div></main></body></html>