コード例 #1
0
 def _open_display(self):
     d_list = [self._video_options["display"]]
     if "DISPLAY" in os.environ:
         d_list.append(os.environ["DISPLAY"])
     for d in d_list:
         try:
             self.__display = x11.X11Display(d_id=d)
         except x11.X11Error:
             continue
         else:
             self.__display.set_dpms(False)
             return
     raise PlayerError(_("Unable to open video display"))
コード例 #2
0
 def get_num_audio_channels(self):
     wanted_output = self.config.get('gstreamer', 'speaker_setup')
     if wanted_output == 'stereo':
         channels = 2
     elif wanted_output == '4channel':
         channels = 4
     elif wanted_output == '5channel':
         channels = 5
     elif wanted_output == '51channel':
         channels = 6
     elif wanted_output == 'ac3passthrough':
         channels = -1
     else:
         raise PlayerError(_("'%s' is not allowed for speaker_setup "
                             "option") % wanted_output)
     return channels
コード例 #3
0
def init(config):
    global INITED
    if INITED:
        return
    else:
        INITED = True

    # Enable error messages by default
    if Gst.debug_get_default_threshold() == Gst.DebugLevel.NONE:
        Gst.debug_set_default_threshold(Gst.DebugLevel.ERROR)

    if not Gst.Element.make_from_uri(
            Gst.URIType.SRC, "file:///fake/path/for/gst", ""):
        raise PlayerError(
            _("Unable to open input files"),
            _("GStreamer has no element to handle reading files. Check "
                "your GStreamer installation settings."))
コード例 #4
0
ファイル: vlc.py プロジェクト: niol/deejayd
    def __prepare_x_window(self):
        d_list = [self._video_options["display"]]
        if "DISPLAY" in os.environ:
            d_list.append(os.environ["DISPLAY"])
        display_ids = iter(d_list)
        try:
            while self.__display is None:
                display_id = next(display_ids)
                try:
                    self.__display = x11.X11Display(d_id=display_id)
                except (x11.X11Error, KeyError):
                    self.__display = None
        except StopIteration:
            raise PlayerError(_("Unable to open video display"))

        self.__display.set_dpms(False)
        if self._video_options["fullscreen"]:
            self.__window = x11.X11Window(self.__display, fullscreen=True)
        else:
            self.__window = x11.X11Window(self.__display,
                                          width=400,
                                          height=200)
コード例 #5
0
ファイル: vlc.py プロジェクト: niol/deejayd
    def play(self):
        if self._playing_media is None:
            return

        playing = False
        uris = iter(self._playing_media.get_uris())
        try:
            while not playing:
                uri = next(uris)
                media = self.__vlc.media_new(uri)
                self.__player.set_media(media)
                needs_video = self.video_enable and self._playing_media.has_video(
                )
                if needs_video and self.__window is None:
                    self.__prepare_x_window()
                    self.__player.set_xwindow(self.__window.window_p())

                self.__playing_handler = VlcPlayer.PlayingEventHandler(
                    self.__evt_manager)
                self.__player.play()
                self.__playing_handler.wait(3)
                playing = self.__playing_handler.get_playing()
                self.__playing_handler.release(self.__evt_manager)
        except StopIteration:
            raise PlayerError(
                _("unable to play file "
                  "%s") % self._playing_media['title'])
        else:
            # check metadata periodically if necessary
            if self._playing_media.need_metadata_refresh():
                self.__metadata_task.start(2)

            # restore video state for this media
            if self._playing_media.has_video():
                p_state = self._playing_media["playing_state"]
                self._player_set_zoom(p_state["zoom"])
                self._player_set_aspectratio(p_state["aspect-ratio"])
コード例 #6
0
ファイル: vlc.py プロジェクト: niol/deejayd
 def _player_set_suboffset(self, offset):
     if self.__player.video_set_spu_delay(offset * 1000) == -1:  # error
         raise PlayerError(_("Unable to update spu delay"))
コード例 #7
0
ファイル: vlc.py プロジェクト: niol/deejayd
 def _player_set_avoffset(self, offset):
     if self.__player.audio_set_delay(offset * 1000) == -1:  # error
         raise PlayerError(_("Unable to update audio/video delay"))
コード例 #8
0
ファイル: _base.py プロジェクト: niol/deejayd
    def set_aspectratio(self, aspect):
        if aspect not in self.aspect_ratios:
            raise PlayerError(_("Video aspect ratio %s is not known") % aspect)

        self._player_set_aspectratio(aspect)
        self.osd(_("Video aspect ratio: %s") % aspect)
コード例 #9
0
ファイル: mpv.py プロジェクト: niol/deejayd
 def base_cb(msg, cmd):
     del self.__commands_cb[cmd['request_id']]
     if 'error' in msg and msg['error'] != 'success':
         raise PlayerError(cmd, msg)
     return msg