Include all files
This commit is contained in:
+11
-8
@@ -2,9 +2,8 @@
|
||||
|
||||
import logging
|
||||
from collections.abc import Callable
|
||||
from typing import Optional, Union, List, Any
|
||||
from pathlib import Path
|
||||
from threading import Lock
|
||||
from typing import List, Optional, Union
|
||||
|
||||
from mpv import MPV
|
||||
|
||||
@@ -24,8 +23,8 @@ class MpvMediaPlayer:
|
||||
self._done_callback: Optional[Callable[[], None]] = None
|
||||
self._done_callback_lock = Lock()
|
||||
|
||||
self._duck_volume:int = 50
|
||||
self._unduck_volume:int = 100
|
||||
self._duck_volume: int = 50
|
||||
self._unduck_volume: int = 100
|
||||
|
||||
self.player.event_callback("end-file")(self._on_end_file)
|
||||
|
||||
@@ -33,6 +32,7 @@ class MpvMediaPlayer:
|
||||
self,
|
||||
url: Union[str, List[str]],
|
||||
done_callback: Optional[Callable[[], None]] = None,
|
||||
stop_first: bool = True,
|
||||
) -> None:
|
||||
self.stop()
|
||||
|
||||
@@ -41,9 +41,12 @@ class MpvMediaPlayer:
|
||||
else:
|
||||
self._playlist = url
|
||||
|
||||
next_url = self._playlist.pop(0)
|
||||
_LOGGER.debug("Playing %s", next_url)
|
||||
|
||||
self._done_callback = done_callback
|
||||
self.is_playing = True
|
||||
self.player.play(self._playlist.pop(0))
|
||||
self.player.play(next_url)
|
||||
|
||||
def pause(self) -> None:
|
||||
self.player.pause = True
|
||||
@@ -71,7 +74,7 @@ class MpvMediaPlayer:
|
||||
self._unduck_volume = volume
|
||||
self._duck_volume = volume // 2
|
||||
|
||||
def _on_end_file(self, event):
|
||||
def _on_end_file(self, event) -> None:
|
||||
if self._playlist:
|
||||
self.player.play(self._playlist.pop(0))
|
||||
return
|
||||
@@ -87,5 +90,5 @@ class MpvMediaPlayer:
|
||||
if todo_callback:
|
||||
try:
|
||||
todo_callback()
|
||||
except:
|
||||
pass
|
||||
except Exception:
|
||||
_LOGGER.exception("Unexpected error running done callback")
|
||||
|
||||
Reference in New Issue
Block a user