0

I made a terminal application with a spiffy GUI. now I'm trying to play videos from this applications using the python vlc bindings. The problem is that when i try all the errors dump out into the terminal, completely ruining the interface.

Is there any way to hide the errors that VLC output using it bindings?

The code that launches VLC is as follows:

inst = vlc.Instance('-q')
media = inst.media_new(vidUrl)
player = inst.media_player_new(vidUrl)
player.play()

There is no way i can resolve the errors, as it's due to the videofiles being streamed, but the server being a little unreliable.

Delusional Logic
  • 780
  • 8
  • 30
  • please see http://stackoverflow.com/questions/5081657/how-do-i-prevent-a-c-shared-library-to-print-on-stdout-in-python – kraymer Apr 17 '15 at 15:42

1 Answers1

0

This will suppress your python errors from being printed into the terminal. Make sure you wrap it around only the parts you don't want stuff to print.

import sys
class NullOutput():
    def write(self, s):
        pass #Don't do anything

def shutup():
    orig = sys.stdout #Save original output
    sys.stdout = NullOutput() #set standard output to nothing
    return orig

def talk(orig):
    sys.stdout = orig #Reset standard output


orig = shutup()
dostuff()
talk()
algorytmus
  • 819
  • 1
  • 9
  • 26
sihrc
  • 2,533
  • 2
  • 17
  • 40
  • I tried this, i even tried doing the same with STDERR. the vlc binding seems to ignore it, it might be because it's based on ctypes, and it doesn't block. – Delusional Logic Aug 03 '13 at 21:15