How to use the castero.player.Player function in castero

To help you get started, we’ve selected a few castero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xgi / castero / tests / test_menu_queue.py View on Github external
from unittest import mock

from castero.episode import Episode
from castero.player import Player
from castero.queue import Queue
from castero.feed import Feed
from castero.menus.queuemenu import QueueMenu

feed = mock.MagicMock(spec=Feed)
player1 = mock.MagicMock(spec=Player)
player2 = mock.MagicMock(spec=Player)
player1.episode = mock.MagicMock(spec=Episode)
window = mock.MagicMock()
window.getmaxyx = mock.MagicMock(return_value=(40, 80))
source = mock.MagicMock(spec=Queue)
source.__iter__.return_value = [player1, player2]
source.__getitem__.return_value = player1


def test_menu_queue_init():
    mymenu = QueueMenu(window, source)
    assert isinstance(mymenu, QueueMenu)


def test_menu_queue_update_items():
    mymenu = QueueMenu(window, source)
github xgi / castero / tests / test_menu_queue.py View on Github external
from unittest import mock

from castero.episode import Episode
from castero.player import Player
from castero.queue import Queue
from castero.feed import Feed
from castero.menus.queuemenu import QueueMenu

feed = mock.MagicMock(spec=Feed)
player1 = mock.MagicMock(spec=Player)
player2 = mock.MagicMock(spec=Player)
player1.episode = mock.MagicMock(spec=Episode)
window = mock.MagicMock()
window.getmaxyx = mock.MagicMock(return_value=(40, 80))
source = mock.MagicMock(spec=Queue)
source.__iter__.return_value = [player1, player2]
source.__getitem__.return_value = player1


def test_menu_queue_init():
    mymenu = QueueMenu(window, source)
    assert isinstance(mymenu, QueueMenu)


def test_menu_queue_update_items():
    mymenu = QueueMenu(window, source)
    mymenu.update_items(None)
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_first(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    assert myqueue.first == player1
github xgi / castero / tests / test_queue.py View on Github external
def test_queue_toggle(display):
    myqueue = Queue(display)
    player1 = mock.MagicMock(spec=Player)

    myqueue.add(player1)
    myqueue.toggle()
    assert player1.play.call_count == 1
    player1.state = 1
    myqueue.toggle()
    assert player1.pause.call_count == 1
github xgi / castero / castero / perspectives / simpleperspective.py View on Github external
This method will not clear the queue prior to adding the new player(s),
        nor will it play the episodes after running.
        """
        if self._active_window == 0:
            feed = self._feed_menu.item
            if feed is not None:
                for episode in self._display.database.episodes(feed):
                    player = Player.create_instance(
                        self._display.AVAILABLE_PLAYERS, str(episode),
                        episode.get_playable(), episode)
                    self._display.queue.add(player)
        elif self._active_window == 1:
            episode = self._episode_menu.item
            if episode is not None:
                player = Player.create_instance(
                    self._display.AVAILABLE_PLAYERS, str(episode),
                    episode.get_playable(), episode)
                self._display.queue.add(player)
github xgi / castero / castero / perspectives / primaryperspective.py View on Github external
This method will not clear the queue prior to adding the new player(s),
        nor will it play the episodes after running.
        """
        if self._active_window == 0:
            feed = self._feed_menu.item
            if feed is not None:
                for episode in self._display.database.episodes(feed):
                    player = Player.create_instance(
                        self._display.AVAILABLE_PLAYERS, str(episode),
                        episode.get_playable(), episode)
                    self._display.queue.add(player)
        elif self._active_window == 1:
            episode = self._episode_menu.item
            if episode is not None:
                player = Player.create_instance(
                    self._display.AVAILABLE_PLAYERS, str(episode),
                    episode.get_playable(), episode)
                self._display.queue.add(player)
github xgi / castero / castero / perspectives / primaryperspective.py View on Github external
def _create_player_from_selected(self) -> None:
        """Creates player(s) based on the selected items and adds to the queue.

        If the active menu is the feed menu, then this will create players for
        all episodes in the selected feed. If the active menu is the episode
        menu, this will simply create a single player.

        This method will not clear the queue prior to adding the new player(s),
        nor will it play the episodes after running.
        """
        if self._active_window == 0:
            feed = self._feed_menu.item
            if feed is not None:
                for episode in self._display.database.episodes(feed):
                    player = Player.create_instance(
                        self._display.AVAILABLE_PLAYERS, str(episode),
                        episode.get_playable(), episode)
                    self._display.queue.add(player)
        elif self._active_window == 1:
            episode = self._episode_menu.item
            if episode is not None:
                player = Player.create_instance(
                    self._display.AVAILABLE_PLAYERS, str(episode),
                    episode.get_playable(), episode)
                self._display.queue.add(player)
github xgi / castero / castero / perspectives / simpleperspective.py View on Github external
def _create_player_from_selected(self) -> None:
        """Creates player(s) based on the selected items and adds to the queue.

        If the active menu is the feed menu, then this will create players for
        all episodes in the selected feed. If the active menu is the episode
        menu, this will simply create a single player.

        This method will not clear the queue prior to adding the new player(s),
        nor will it play the episodes after running.
        """
        if self._active_window == 0:
            feed = self._feed_menu.item
            if feed is not None:
                for episode in self._display.database.episodes(feed):
                    player = Player.create_instance(
                        self._display.AVAILABLE_PLAYERS, str(episode),
                        episode.get_playable(), episode)
                    self._display.queue.add(player)
        elif self._active_window == 1:
            episode = self._episode_menu.item
            if episode is not None:
                player = Player.create_instance(
                    self._display.AVAILABLE_PLAYERS, str(episode),
                    episode.get_playable(), episode)
                self._display.queue.add(player)
github xgi / castero / castero / players / vlcplayer.py View on Github external
import time

from castero.player import Player, PlayerDependencyError


class VLCPlayer(Player):
    """Interface for the vlc media player.
    """
    NAME = "vlc"

    def __init__(self, title, path, episode) -> None:
        """
        Overrides method from Player; see documentation in that class.
        """
        super().__init__(title, path, episode)

        import vlc
        self.vlc = vlc

    @staticmethod
    def check_dependencies():
        """Checks whether dependencies are met for playing a player.
github xgi / castero / castero / players / mpvplayer.py View on Github external
import time

from castero.player import Player, PlayerDependencyError


class MPVPlayer(Player):
    """Interface for the mpv media player.
    """
    NAME = "mpv"

    def __init__(self, title, path, episode) -> None:
        """
        Overrides method from Player; see documentation in that class.
        """
        super().__init__(title, path, episode)

        import mpv
        self.mpv = mpv

    @staticmethod
    def check_dependencies():
        """Checks whether dependencies are met for playing a player.