コード例 #1
0
ファイル: mkchromecast.py プロジェクト: xmbwd/mkchromecast
    def audio_linux(self):
        """This method manages all related to casting audio in Linux"""
        if self.youtubeurl == None and self.source_url == None:
            if adevice == None:
                print('Creating Pulseaudio Sink...')
                print(
                    colors.warning(
                        'Open Pavucontrol and Select the Mkchromecast Sink.'))
                create_sink()
            print(colors.important('Starting Local Streaming Server'))
            print(colors.success('[Done]'))
            self.start_backend(self.encoder_backend)
            self.cc.initialize_cast()
            self.get_cc(self.select_cc)
            self.cc.play_cast()
            self.show_control(self.control)

        elif self.youtubeurl == None and self.source_url != None:
            self.start_backend(self.encoder_backend)
            self.cc.initialize_cast()
            self.get_cc(self.select_cc)
            self.cc.play_cast()
            self.show_control(self.control)

        elif youtubeurl != None and self.videoarg == False:  # When casting youtube url, we do it through the audio module
            import mkchromecast.audio
            mkchromecast.audio.main()
            self.cc.initialize_cast()
            self.get_cc(self.select_cc)
            self.cc.play_cast()
            self.show_control(self.control)
コード例 #2
0
    def _play_cast_(self):
        if os.path.exists(configf):
            print(colors.warning(":::Threading::: Configuration file exists."))
            print(colors.warning(":::Threading::: Using defaults set there."))
            config.read(configf)
            backend = ConfigSectionMap("settings")["backend"]
            print(":::Threading backend::: %s." % backend)
        else:
            backend = mkchromecast.__init__.backend
        global cast
        if backend == "node":
            stream()
        else:
            try:
                reload(mkchromecast.audio)
            except NameError:
                from imp import reload

                reload(mkchromecast.audio)
            mkchromecast.audio.main()
        if platform == "Linux":
            # We create the sink only if it is not available
            if check_sink() is False and adevice is None:
                create_sink()

        start = Casting()
        start.initialize_cast()
        try:
            start.get_devices()
            start.play_cast()
            cast = start.cast
            # Let's change inputs at the end to avoid muting sound too early.
            # For Linux it does not matter given that user has to select sink
            # in pulse audio.  Therefore the sooner it is available, the
            # better.
            if platform == "Darwin":
                inputdev()
                outputdev()
            self.pcastready.emit("_play_cast_ success")
        except AttributeError:
            self.pcastready.emit("_play_cast_ failed")
        self.pcastfinished.emit()
コード例 #3
0
    def _play_cast_(self):
        if os.path.exists(configf):
            print(colors.warning(':::Threading::: Configuration file exists.'))
            print(colors.warning(':::Threading::: Using defaults set there.'))
            config.read(configf)
            backend = ConfigSectionMap('settings')['backend']
            print(':::Threading backend::: %s.' % backend)
        else:
            backend = mkchromecast.__init__.backend
        global cast
        if backend == 'node':
            stream()
        else:
            try:
                reload(mkchromecast.audio)
            except NameError:
                from imp import reload
                reload(mkchromecast.audio)
            mkchromecast.audio.main()
        if platform == 'Linux':
            # We create the sink only if it is not available
            if check_sink() is False and adevice is None:
                create_sink()

        start = Casting()
        start.initialize_cast()
        try:
            start.get_devices()
            start.play_cast()
            cast = start.cast
            # Let's change inputs at the end to avoid muting sound too early.
            # For Linux it does not matter given that user has to select sink
            # in pulse audio.  Therefore the sooner it is available, the
            # better.
            if platform == 'Darwin':
                inputdev()
                outputdev()
            self.pcastready.emit('_play_cast_ success')
        except AttributeError:
            self.pcastready.emit('_play_cast_ failed')
        self.pcastfinished.emit()