Skip to content

Commit

Permalink
Fixes for mpv 0.36 and Nim 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zedeus committed Nov 12, 2023
1 parent cb73493 commit cb84962
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions config.nims
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--define:ssl
--gc:orc
--threads:off
warning("GcUnsafe2", off)
14 changes: 8 additions & 6 deletions src/kino_mpv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,18 @@ proc handleMpv() {.async.} =

let event = resp{"event"}.getStr
case event
of "pause", "unpause":
let playing = event == "unpause"
if not loading:
syncPlaying(playing)
player.playing = playing
of "property-change":
if resp{"name"}.getStr == "playlist-pos":
case resp{"name"}.getStr
of "playlist-pos":
player.index = resp{"data"}.getInt(-1)
if not reloading:
syncIndex(player.index)
of "core-idle":
# true means paused
let playing = not resp{"data"}.getBool(false)
if not loading:
syncPlaying(playing)
player.playing = playing
of "seek":
player.getTime()
loading = true
Expand Down
5 changes: 3 additions & 2 deletions src/kino_web.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import std/[dom, strformat, sequtils]
import std/[strformat, sequtils]
import std/dom except matchMedia
from sugar import `=>`
import websockets, patty
include karax / prelude
include karax/prelude
import protocol, web/plyr

type
Expand Down
1 change: 1 addition & 0 deletions src/mpv/mpv.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ proc startMpv*(path: string): Future[Mpv] {.async.} =
mpv.sock = openAsync(fd, fmReadWrite)

command ["observe_property", 1, "playlist-pos"]
command ["observe_property", 2, "core-idle"]
except:
echo "Failed to connect to mpv socket"
terminate mpv.process
Expand Down

0 comments on commit cb84962

Please sign in to comment.