Add musicplayer module that wraps all logic
This commit is contained in:
@@ -1,22 +1,32 @@
|
||||
import gleam/erlang/process.{type Name}
|
||||
|
||||
import musicplayer/input/input.{type Listener}
|
||||
import musicplayer/input/input
|
||||
import musicplayer/input/key.{type Key}
|
||||
import musicplayer/mpv/mpv
|
||||
import musicplayer/musicplayer
|
||||
|
||||
pub fn main() -> Nil {
|
||||
let exit = process.new_subject()
|
||||
let input_keys_name: Name(Key) = process.new_name("input_keys")
|
||||
let input_stream_name: Name(List(String)) = process.new_name("input_stream")
|
||||
|
||||
// `inject_input` is created by name to allow the `input` process that
|
||||
// `input_inject` is created by name to allow the `input` process that
|
||||
// owns `read_input` to be able to register and receive from it,
|
||||
// while the any other processes can use the name reference to
|
||||
// inject input
|
||||
let inject_input_name: Name(Key) = process.new_name("inject_input")
|
||||
let input_inject_name: Name(Key) = process.new_name("input_inject_keys")
|
||||
|
||||
let assert Ok(mpv_listener) = mpv.new(exit)
|
||||
input.new(input_keys_name, input_stream_name, input_inject_name)
|
||||
|
||||
let listeners: List(Listener) = [mpv_listener]
|
||||
let assert Ok(mpv) = mpv.new()
|
||||
|
||||
input.new(listeners, inject_input_name)
|
||||
let exit = process.new_subject()
|
||||
let assert Ok(_) =
|
||||
musicplayer.new(
|
||||
mpv,
|
||||
input_keys_name,
|
||||
input_stream_name,
|
||||
input_inject_name,
|
||||
exit,
|
||||
)
|
||||
process.receive_forever(exit)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user