当前位置: 首页>>代码示例>>Python>>正文


Python discord.FFmpegPCMAudio方法代码示例

本文整理汇总了Python中discord.FFmpegPCMAudio方法的典型用法代码示例。如果您正苦于以下问题:Python discord.FFmpegPCMAudio方法的具体用法?Python discord.FFmpegPCMAudio怎么用?Python discord.FFmpegPCMAudio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.FFmpegPCMAudio方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: modofail

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def modofail(ctx: MtgContext, args: Optional[str]) -> None:
    """Ding!"""
    if args is not None and args.lower() == 'reset':
        redis.clear(f'modofail:{ctx.guild}')
    author = ctx.author
    if isinstance(author, Member) and hasattr(author, 'voice') and author.voice is not None and author.voice.channel is not None:
        voice_channel = ctx.author.voice.channel
        voice = ctx.channel.guild.voice_client
        if voice is None:
            voice = await voice_channel.connect()
        elif voice.channel != voice_channel:
            voice.move_to(voice_channel)
        voice.play(FFmpegPCMAudio('ding.ogg'))
    n = redis.increment(f'modofail:{ctx.guild}')
    redis.expire(f'modofail:{ctx.guild}', 3600)
    await ctx.send(f':bellhop: **MODO fail** {n}') 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:18,代码来源:modofail.py

示例2: play_next_clip

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def play_next_clip(self):
		clip = self.next_clip()

		try:
			self.voice.play(discord.FFmpegPCMAudio(clip.audiopath), after=self.done_talking)
		except discord.errors.ClientException as e:
			if str(e) == "Not connected to voice.":
				raise UserError("Error playing clip. Try doing `?resummon`.")
			else:
				raise

		self.voice.source = discord.PCMVolumeTransformer(self.voice.source)
		self.voice.source.volume = clip.volume
		print("playing: " + clip.audiopath)
		if self.last_clip != None and clip.audiopath != self.last_clip.audiopath:
			remove_if_temp(self.last_clip.audiopath)
		self.last_clip = clip

	# try queueing an mp3 to play 
开发者ID:mdiller,项目名称:MangoByte,代码行数:21,代码来源:audio.py

示例3: on_ready

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def on_ready():
    await asyncio.sleep(1)
    voice_channel = client.get_channel(int(voice_id))
    while not client.is_closed():
        vc = await voice_channel.connect()
        vc.play(discord.FFmpegPCMAudio(filename))
        vc.source = discord.PCMVolumeTransformer(vc.source)
        vc.source.volume = 10.0
        while vc.is_playing():
            if sys.platform.startswith('linux'):
                proc = psutil.Process(int(parentprocess))
                if proc.status() == psutil.STATUS_ZOMBIE:
                    await client.logout()
                    sys.exit()
            if not psutil.pid_exists(int(parentprocess)):  # Parent is dead, Kill self :cry:
                await client.logout()
                sys.exit()
            await asyncio.sleep(0.5)
        await vc.disconnect(force=True) 
开发者ID:DeadBread76,项目名称:Raid-Toolbox,代码行数:21,代码来源:vcspam.py

示例4: create_source

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def create_source(cls, ctx, search: str, *, loop, download=False):
        loop = loop or asyncio.get_event_loop()

        to_run = partial(ytdl.extract_info, url=search, download=download)
        data = await loop.run_in_executor(None, to_run)

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        await ctx.send(f':notes: Added to queue: **{data["title"]}**')

        if download:
            source = ytdl.prepare_filename(data)
        else:
            return {'webpage_url': data['webpage_url'], 'requester': ctx.author, 'title': data['title']}

        return cls(discord.FFmpegPCMAudio(source), data=data, requester=ctx.author) 
开发者ID:F4stZ4p,项目名称:DJ5n4k3,代码行数:20,代码来源:music.py

示例5: play_

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def play_(self, ctx, *, search: str):
        """Request a song and add it to the queue.

        This command attempts to join a valid voice channel if the bot is not already in one.
        Uses YTDL to automatically search and retrieve a song.

        Parameters
        ------------
        search: str [Required]
            The song to search and retrieve using YTDL. This could be a simple search, an ID or URL.
        """
        await ctx.trigger_typing()

        vc = ctx.voice_client

        if not vc:
            await ctx.invoke(self.connect_)

        elif ctx.author not in ctx.guild.voice_client.channel.members:
            return await ctx.send(":notes: Please join my voice channel to execute this command.", delete_after=20)

        player = self.get_player(ctx)

        # If download is False, source will be a dict which will be used later to regather the stream.
        # If download is True, source will be a discord.FFmpegPCMAudio with a VolumeTransformer.
        source = await YTDLSource.create_source(ctx, search, loop=self.bot.loop, download=False)
        await player.queue.put(source) 
开发者ID:F4stZ4p,项目名称:DJ5n4k3,代码行数:29,代码来源:music.py

示例6: from_url

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def from_url(cls, url, *, loop=None, stream=False):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        filename = data['url'] if stream else ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:12,代码来源:basic_voice.py

示例7: play

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def play(self, ctx, *, query):
        """Plays a file from the local filesystem"""

        source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
        ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None)

        await ctx.send('Now playing: {}'.format(query)) 
开发者ID:Rapptz,项目名称:discord.py,代码行数:9,代码来源:basic_voice.py

示例8: create_player

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def create_player(self, voice_client):
        """
        Creates a player instance for a voice client
        to deliver the item's music data to.
        :param voice_client: The voice client to use for delivery.
        :type voice_client: discord.VoiceClient
        :return:
        :rtype:
        """
        await self.download()
        if self.location:
            audio_source = discord.FFmpegPCMAudio(self.location)
            if voice_client:
                if not voice_client.is_playing():
                    voice_client.play(audio_source) 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:17,代码来源:music.py

示例9: spookysound

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def spookysound(self, ctx: commands.Context) -> None:
        """
        Connect to the Hacktoberbot voice channel, play a random spooky sound, then disconnect.

        Cannot be used more than once in 2 minutes.
        """
        if not self.channel:
            await self.bot.wait_until_guild_available()
            self.channel = self.bot.get_channel(Hacktoberfest.voice_id)

        await ctx.send("Initiating spooky sound...")
        file_path = random.choice(self.sound_files)
        src = discord.FFmpegPCMAudio(str(file_path.resolve()))
        voice = await self.channel.connect()
        voice.play(src, after=lambda e: self.bot.loop.create_task(self.disconnect(voice))) 
开发者ID:python-discord,项目名称:seasonalbot,代码行数:17,代码来源:spookysound.py

示例10: regather_stream

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def regather_stream(cls, data, *, loop):
        """Used for preparing a stream, instead of downloading.

        Since Youtube Streaming links expire."""
        loop = loop or asyncio.get_event_loop()
        requester = data['requester']

        to_run = partial(ytdl.extract_info, url=data['webpage_url'], download=False)
        data = await loop.run_in_executor(None, to_run)

        return cls(discord.FFmpegPCMAudio(data['url']), data=data, requester=requester) 
开发者ID:F4stZ4p,项目名称:DJ5n4k3,代码行数:13,代码来源:music.py

示例11: from_url

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def from_url(cls, url, *, loop=None):
        loop = loop or asyncio.get_event_loop()
        data = await loop.run_in_executor(None, ytdl.extract_info, url)

        if 'entries' in data:
            # take first item from a playlist
            data = data['entries'][0]

        filename = ytdl.prepare_filename(data)
        return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) 
开发者ID:shibdib,项目名称:Firetail,代码行数:12,代码来源:stream_player.py

示例12: music_player_main

# 需要导入模块: import discord [as 别名]
# 或者: from discord import FFmpegPCMAudio [as 别名]
def music_player_main(voice_channel,server):
    vc = await voice_channel.connect()
    while True:
        clear()
        print(colored("Channel: {}".format(voice_channel.name),menucolour))
        print()
        print(colored("1. Play YouTube Link.",menucolour))
        print(colored("2. Pause Player",menucolour))
        print(colored("3. Resume Player",menucolour))
        print(colored("4. Stop Player",menucolour))
        print(colored("5. Volume Adjustment",menucolour))
        print(colored("6. Disconnect",menucolour))
        try:
            player_choice = await loop.run_in_executor(ThreadPoolExecutor(), inputselection,'Option: ')
            if int(player_choice) == 1:
                clear()
                url = await loop.run_in_executor(ThreadPoolExecutor(), inputselection,'YouTube Link to play: ')
                try:
                    if os.path.isfile('RTBFiles/ServerSmasher/file.mp3'):
                        os.remove('RTBFiles/ServerSmasher/file.mp3')
                        print ("Removed old .mp3.")
                    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                        ydl.download([url])
                    vc.play(discord.FFmpegPCMAudio('RTBFiles/ServerSmasher/file.mp3'))
                    vc.source = discord.PCMVolumeTransformer(vc.source)
                    vc.source.volume = 1.0
                except Exception as e:
                    await loop.run_in_executor(ThreadPoolExecutor(), inputselection, str(e))
            elif int(player_choice) == 2:
                vc.pause()
            elif int(player_choice) == 3:
                vc.resume()
            elif int(player_choice) == 4:
                vc.stop()
            elif int(player_choice) == 5:
                clear()
                newvol = await loop.run_in_executor(ThreadPoolExecutor(), inputselection,'New Volume: ')
                try:
                    vc.source.volume = float(int(newvol))
                except Exception as e:
                    await loop.run_in_executor(ThreadPoolExecutor(), inputselection,e)
            elif int(player_choice) == 6:
                await vc.disconnect(force=True)
                await music_player_channel_select(server)
        except Exception as e:
            continue 
开发者ID:DeadBread76,项目名称:Raid-Toolbox,代码行数:48,代码来源:serversmasher.py


注:本文中的discord.FFmpegPCMAudio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。