Recherche avancée

Médias (91)

Autres articles (11)

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Les thèmes de MediaSpip

    4 juin 2013

    3 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
    Thèmes MediaSPIP
    3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)

Sur d’autres sites (3762)

  • The bot doesn't play music (discord.py)

    30 avril 2024, par Naydar

    The code works fine, but when using the command in guild the bot enters the voice channel but doesn't play music, immediately console gives : ffmpeg process 56560 successfully terminated with return code of 3199971767.

    


    import discord
import youtube_dl
import ffmpeg
import requests
from discord.ext import commands

class music(commands.Cog, name = 'music'):
    def __init__(self, bot):
        self.bot = bot

        self.is_playing = False
        self.is_paused = False


        self.music_queue = []
        self.YTDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
        self.FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn -filter "volume=0.25"'}

        self.voice_client = None
        
    @commands.command(name="play")
    async def play(self, ctx, url):
        if not ctx.message.author.voice:
            await ctx.send("You are not connected to a voice channel.")
            return

        self.voice_channel = ctx.message.author.voice.channel
        if self.voice_client and self.voice_client.is_connected():
            await self.voice_client.move_to(self.voice_channel)
        else:
            self.voice_client = await self.voice_channel.connect()

        api_key = "my_key"
        video_id = url.split("v=")[1]
        api_url = f"https://www.googleapis.com/youtube/v3/videos?part=snippet&id={video_id}&key={api_key}"

        response = requests.get(api_url)
        if response.status_code == 200:
            data = response.json()
            title = data["items"][0]["snippet"]["title"]
            audio_url = f"https://www.youtube.com/watch?v={video_id}"
            self.voice_client.play(discord.FFmpegOpusAudio(audio_url))
            await ctx.send("Now playing: " + title)
        else:
            await ctx.send("Unable to fetch video information.")

async def setup(bot):
    await bot.add_cog(music(bot))


    


    I tried to rewrite some YTDL and FFMPEG options
(tried to replace "noplaylist" option on "False" and terminal sent :
"discord.player : ffmpeg process 51124 successfully terminated with return code of 4294967295").
Also i checked the updates of modules.

    


  • ffmpeg doesn't work, when starting up it doesn't play music, it gives errors

    14 août 2024, par Оля Михеева
    import discord
from discord import FFmpegPCMAudio
import os
import random
from gtts import gTTS
import asyncio

TOKEN="***"
VOICE_CHANNEL_ID=11122224444

class Voice_Bot(discord.Client):
    def __init__(self):
        intents = discord.Intents.default()
        intents.message_content = True
        intents.voice_states=True
        super().__init__(intents=intents)
        print(os.getcwd())
        self.sounds_hello = os.listdir(os.path.join('sounds','hello'))
        self.sounds_bye = os.listdir('sounds\\bye')
        self.sounds = os.listdir('sounds\\nature')

    async def on_ready(self):        
        self.voice_channel = self.get_channel(VOICE_CHANNEL_ID) 
        if self.voice_channel == None:
            print('Не удалось подключиться к голосовому каналу.')
            return
        self.voice_client = await self.voice_channel.connect()
        print('Бот подключен к голосовому каналу')
        await self.text_to_speech("Lets play Guess the Tune")
        
    async def on_message(self,message):
        if message.author==self.user:
            return
        if message.content.startswith("game"):
            await self.text_to_speech("let's start the game guess the melody")
            music=os.listdir("sounds\\music")
            self.melody=random.choice(music)
            await self.play_sound(f"sounds\\music\\{self.melody}")
        elif message.content==self.melody[0:len(self.melody)-4]:
            if (self.voice_client.is_playing()):
                self.voice_client.stop()
            await self.text_to_speech(f"Congratulations, {message.author.name} answered correctly! To continue, type game")
        else:
            if (self.voice_client.is_playing()):
                self.voice_client.stop()
            await self.text_to_speech(f"Unfortunately, {message.author.name} did not guess. To continue, write game")


    async def on_voice_state_update(self,member,before,after):
        if member.id ==self.user.id:
            print('Someone entered or left the voice channel.')
        else:
            try:
                if before.channel == None:
                    print(f'{member.name} entered the voice channel {after.channel}.')
                    await self.play_sound(f'sounds\\hello\\{random.choice(self.sounds_hello)}')
                elif after.channel == None:
                    print(f'{member.name} left the voice channel {before.channel}.')
                    await self.play_sound(f'sounds\\bye\\{random.choice(self.sounds_bye)}')
            except Exception as e:
                print(f"Error in on_voise_state_update: {e}")

    async def text_to_speech(self,text):
        try:
            tts = gTTS(text=text, lang ="en")
            tts.save("text.mp3")
        except Exception as e:
            print(f"Error e: {e}")
        await self.voice_channel.send(text)
        await self.play_sound("text.mp3")

    def play_sound(self,path):
        print(path)
        source=discord.FFmpegPCMAudio(source=path, executable="ffmpeg\\bin\\ffmpeg.exe")
        if (self.voice_client.is_playing()):
            self.voice_client.stop()
        self.voice_client.play(source)                

client = Voice_Bot()
client.run(TOKEN)


    


    [enter image description here](https://i.sstatic.net/ys8Xza0w.jpg)

    


  • Python Discord Music Bot : Playing next song while current song is playing

    8 février, par Deltrac

    I've been working on a Discord bot and got it working 90% of the time. On some occasions, the bot will be playing a song and it will stop playing and just move to the next song. My assumption is that it's because of how I am handling my play command and the play_next command as well.

    


    I've tried to re-arrange the code, change functionality, etc. without success.

    


    Here are the two commands :

    


    @client.command(name="p")
async def play(ctx, *, search_query: str):
        global bot_disconnect
        try:
        # Only start a song if the user trying to play a song is in a voice channel
            if ctx.author.voice:
                voice_channel = ctx.author.voice.channel
                voice_client = await voice_channel.connect() # Find who played the song and have the bot enter that channel
                voice_clients[voice_client.guild.id] = voice_client
            else:
                await ctx.channel.send("Get in a voice channel")
                return
        except Exception as e:
                print(e)
        try:
            if is_youtube_url(search_query):
                loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False))
                video_url = data["webpage_url"] # Save the youtube video URL to variable
                song_url = data["url"] # Save the extracted URL to a variable
                title = data["title"]
            else:
                url = f"ytsearch:{search_query}"
                loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
                data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download = False)) 
                entry = data['entries'][0]
                video_url = entry["webpage_url"] # Save the youtube video URL to variable
                song_url = entry["url"] # Save the extracted URL to a variable
                title = entry["title"]

            if ctx.guild.id in voice_clients and voice_clients[ctx.guild.id].is_playing():
                await queue(ctx, search_query = video_url, title = title)
            else:
                player = discord.FFmpegOpusAudio(song_url, **ffmpeg_options) # THIS IS WHAT PLAYS THE ACTUAL SONG!!!!!!
                await ctx.channel.send(f"Now Playing: {video_url} \n[DOWNLOAD LINK HERE]({song_url})") # Send the video URL to discord channel and include a download link as well
                bot_disconnect = False
                voice_clients[ctx.guild.id].play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop))
        except Exception as e:
                print(e)



async def play_next(ctx):
    if len(queues) != 0 and queues.get(ctx.guild.id):         
        search_query = queues[ctx.guild.id].pop(0)[0] # Pull the URL from the next index
        loop = asyncio.get_event_loop() # Let's the bot multi-task (Similar behavior to interrupts in C/C++)
        print(f"{search_query}")
        data = await loop.run_in_executor(None, lambda: ytdl.extract_info(search_query, download = False))
        player = discord.FFmpegOpusAudio(data["url"], **ffmpeg_options)
        voice_client = voice_clients[ctx.guild.id]
        voice_client.play(player, after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), client.loop))
        await ctx.channel.send(f"Now Playing: {data['webpage_url']} \n[DOWNLOAD LINK HERE]({data['url']})") # Send the video URL to discord channel and include a download link as well
    else:
        await ctx.send("No songs in queue")


    


    I can also link the full code, if required.