コード例 #1
0
    def from_file(cls, filename, **kwargs):
        """Create a `AudioStream` from a local file.

        Parameters
        ----------
        filename: str
            The location of a file to read into the audio value from disk.
        **kwargs
            Extra keyword arguments for `AudioStream`
        """
        audio = Audio.from_file(filename, autoplay=False, controls=False)
        return cls(audio=audio, **kwargs)
コード例 #2
0
    def from_url(cls, url, **kwargs):
        """Create a `AudioStream` from a url.
        This will create a `AudioStream` from an Audio using its url

        Parameters
        ----------
        url: str
            The url of the file that will be used for the .audio trait.
        **kwargs:
            Extra keyword arguments for `AudioStream`
        Returns an `AudioStream`.
        """
        audio = Audio.from_url(url, autoplay=False, controls=False)
        return cls(audio=audio, **kwargs)
コード例 #3
0
 def from_download(cls, url, **kwargs):
     """Create a `AudioStream` from a url by downloading
     Parameters
     ----------
     url: str
         The url of the file that will be downloadeded and its bytes
         assigned to the value trait of the video trait.
     **kwargs:
         Extra keyword arguments for `AudioStream`
     Returns an `AudioStream` with the value set from the content of a url.
     """
     ext = os.path.splitext(url)[1]
     if ext:
         format = ext[1:]
     audio = Audio(value=urlopen(url).read(), format=format, autoplay=False, controls=False)
     return cls(audio=audio, **kwargs)
コード例 #4
0
 def _default_audio(self):
     return Audio(format=self.format, controls=True)