Recherche avancée

Médias (91)

Autres articles (22)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Ajouter notes et légendes aux images

    7 février 2011, par

    Pour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
    Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
    Modification lors de l’ajout d’un média
    Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...)

  • 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 (...)

Sur d’autres sites (3991)

  • Need Help Making Java Script Discord Music Bot

    2 février 2017, par Gambino

    I have tried to use this code to make a discord music bot but i am getting error telling me i need ffmpeg, but how would I implement it into this code ?

    index.js file

    const Discord = require('discord.js');
    const bot = new Discord.Client();
    const config = require("./config.json");
    const ytdl = require('ytdl-core');

    var youtube = require('./youtube.js');


    var ytAudioQueue = [];
    var dispatcher = null;

    bot.on('message', function(message) {
       var messageParts = message.content.split(' ');
       var command = messageParts[0].toLowerCase();
       var parameters = messageParts.splice(1, messageParts.length);

       switch (command) {

           case "-join" :
           message.reply("Attempting to join channel " + parameters[0]);
           JoinCommand(parameters[0], message);
           break;
       
           case "-play" :
           PlayCommand(parameters.join(" "), message);
           break;

           case "-playqueue":
           PlayQueueCommand(message);
           break;
       }
    });


       function PlayCommand(searchTerm) {
           if(bot.voiceConnections.array().length == 0) {
               var defaultVoiceChannel = bot.channels.find(val => val.type === 'voice').name;
               JoinCommand(defaultVoiceChannel);
           }
           youtube.search(searchTerm, QueueYtAudioStream);
       }

       function PlayQueueCommand(message) {
           var queueString = "";

           for(var x = 0; x < ytAudioQueue.length; x++) {
               queueString += ytAudioQueue[x].videoName + ", ";
           }
           queueString = queueString.substring(0, queueString.length - 2);
           message.reply(queueString);
       }

       function JoinCommand(ChannelName) {
           var voiceChannel = GetChannelByName(ChannelName);

           if (voiceChannel) {
               voiceChannel.join();
               console.log("Joined " + voiceChannel.name);
           }
           
           return voiceChannel;
           
       }

       /* Helper Methods */

       function GetChannelByName(name) {
           var channel = bot.channels.find(val => val.name === name);
           return channel;
       }

     

       function QueueYtAudioStream(videoId, videoName) {
           var streamUrl = youtube.watchVideoUrl + videoId;

           if (!ytAudioQueue.length) {
               ytAudioQueue.push(
                   {
                       'streamUrl' : streamUrl,
                       'videoName' : videoName
                   }
               );
               console.log('Queued audio ' + videoName);
               PlayStream(ytAudioQueue[0].streamUrl);
           }
           else {
               ytAudioQueue.push(
                   {
                       'streamUrl' : streamUrl,
                       'videoName' : videoName
                   }
               );
           }
           console.log("Queued audio " + videoName);
       }

       function PlayStream(streamUrl) {
           const streamOptions = {seek: 0, volume: 1};

           if (streamUrl) {
               const stream = ytdl(streamUrl, {filter: 'audioonly'});

               if (dispatcher == null) {
                   var voiceConnection = bot.voiceConnections.first();

                   if(voiceConnection) {
                       console.log("Now Playing " + ytAudioQueue[0].videoname);
                       dispatcher = bot.voiceConnections.first().playStream(stream, streamOptions);

                       dispatcher.on('end', () => {
                           dispatcher = null;
                           PlayNextStreamInQueue();
                       });

                       dispatcher.on('error', (err) => {
                           console.log(err);
                       });
                   }
               } else {
                   dispatcher = bot.voiceConnections.first().playStream(stream, streamOptions);
               }
               
           }
       }

       function PlayNextStreamInQueue() {
           ytAudioQueue.splice(0, 1);

           if (ytAudioQueue.length != 0) {
               console.log("now Playing " + ytAudioQueue[0].videoName);
               PlayStream(ytAudioQueue[0].streamUrl);
           }
       }


    bot.login(config.token);

    youtube.js file

    var request = require('superagent');

    const API_KEY = "My API KEY";
    const WATCH_VIDEO_URL = "https://www.youtube.com/watch?v=";

    exports.watchVideoUrl = WATCH_VIDEO_URL;

    exports.search = function search(searchKeywords, callback) {
     var requestUrl = 'https://www.googleapis.com/youtube/v3/search' + '?part=snippet&q=' + escape(searchKeywords) + '&key=' + API_KEY;

     request(requestUrl, (error, response) => {
       if (!error && response.statusCode == 200) {

         var body = response.body;
         if (body.items.length == 0) {
           console.log("I Could Not Find Anything!");
           return;
         }
         for (var item of body.items) {
           if (item.id.kind == 'youtube#video') {
             callback(item.id.videoId, item.snippet.title);
             return;
           }
         }
       } else {
         console.log("Unexpected error!");
         return;
       }
     });

     return;

    };

    Error I am getting when I try to run code :

    Joined General

    C :\Discord Bot\node_modules\discord.js\src\client\voice\pcm\FfmpegConverterEngine.

    js:80

    throw new Error(

    ^

    Error : FFMPEG was not found on your system, so audio cannot be played. Please make
    sure FFMPEG is installed and in your PATH.

  • music bot stopping music entirely instead of skipping one song discord.py

    26 septembre 2018, par Y4h L

    When i use my skip command, my program stops playing music, instead of skipping a song.
    Here’s the code :

    queues = {}
    players = {}
    opts = {
               'default_search': 'auto',
               'quiet': True,
           }
    voice_states = {}

    class voice:
       def __init__(self, client):
           self.client = client

       @commands.command(pass_context=True)
       async def skip(self, ctx):
           id = ctx.message.server.id
           players[id].stop()

       @commands.command(
           pass_context=True
       )
       async def play(self, ctx, url):
           server = ctx.message.server
           channel = ctx.message.author.voice.voice_channel
           try:
               await self.client.join_voice_channel(channel)
           except:
               print(" ")
           if server.id not in players or players[server.id].is_done():
               server = ctx.message.server
               voice_client = self.client.voice_client_in(server)
               player = await voice_client.create_ytdl_player(url, after=lambda: queue(server.id), ytdl_options=opts)
               players[server.id] = player
               await self.client.say('Now Playing ' )
               player.start()
           else:
               server = ctx.message.server
               voice_client = self.client.voice_client_in(server)
               player = await voice_client.create_ytdl_player(url, after=lambda: queue(server.id),  ytdl_options=opts)

               if server.id in queues:
                   queues[server.id].append(player)
               else:
                   queues[server.id] = [player]
               await self.client.say('Now Playing ' )
               await self.client.say('Video queued.')

       def queue(self, id):
           if queues[id] != []:
               player = queues[id].pop(0)
               players[id] = player
               player.start()

    def setup(client):
       client.add_cog(voice(client))

    i receive no error codes,
    just no queue.
    Fixes to my code or own solutions are appreciated.
    Sorry, for long code, but you need all the context

  • Need Help Making Java Script Discord Music Bot

    22 octobre 2018, par Gambino

    I have tried to use this code to make a discord music bot but i am getting error telling me i need ffmpeg, but how would I implement it into this code ?

    index.js file

    const Discord = require('discord.js');
    const bot = new Discord.Client();
    const config = require("./config.json");
    const ytdl = require('ytdl-core');

    var youtube = require('./youtube.js');


    var ytAudioQueue = [];
    var dispatcher = null;

    bot.on('message', function(message) {
       var messageParts = message.content.split(' ');
       var command = messageParts[0].toLowerCase();
       var parameters = messageParts.splice(1, messageParts.length);

       switch (command) {

           case "-join" :
           message.reply("Attempting to join channel " + parameters[0]);
           JoinCommand(parameters[0], message);
           break;
       
           case "-play" :
           PlayCommand(parameters.join(" "), message);
           break;

           case "-playqueue":
           PlayQueueCommand(message);
           break;
       }
    });


       function PlayCommand(searchTerm) {
           if(bot.voiceConnections.array().length == 0) {
               var defaultVoiceChannel = bot.channels.find(val => val.type === 'voice').name;
               JoinCommand(defaultVoiceChannel);
           }
           youtube.search(searchTerm, QueueYtAudioStream);
       }

       function PlayQueueCommand(message) {
           var queueString = "";

           for(var x = 0; x < ytAudioQueue.length; x++) {
               queueString += ytAudioQueue[x].videoName + ", ";
           }
           queueString = queueString.substring(0, queueString.length - 2);
           message.reply(queueString);
       }

       function JoinCommand(ChannelName) {
           var voiceChannel = GetChannelByName(ChannelName);

           if (voiceChannel) {
               voiceChannel.join();
               console.log("Joined " + voiceChannel.name);
           }
           
           return voiceChannel;
           
       }

       /* Helper Methods */

       function GetChannelByName(name) {
           var channel = bot.channels.find(val => val.name === name);
           return channel;
       }

     

       function QueueYtAudioStream(videoId, videoName) {
           var streamUrl = youtube.watchVideoUrl + videoId;

           if (!ytAudioQueue.length) {
               ytAudioQueue.push(
                   {
                       'streamUrl' : streamUrl,
                       'videoName' : videoName
                   }
               );
               console.log('Queued audio ' + videoName);
               PlayStream(ytAudioQueue[0].streamUrl);
           }
           else {
               ytAudioQueue.push(
                   {
                       'streamUrl' : streamUrl,
                       'videoName' : videoName
                   }
               );
           }
           console.log("Queued audio " + videoName);
       }

       function PlayStream(streamUrl) {
           const streamOptions = {seek: 0, volume: 1};

           if (streamUrl) {
               const stream = ytdl(streamUrl, {filter: 'audioonly'});

               if (dispatcher == null) {
                   var voiceConnection = bot.voiceConnections.first();

                   if(voiceConnection) {
                       console.log("Now Playing " + ytAudioQueue[0].videoname);
                       dispatcher = bot.voiceConnections.first().playStream(stream, streamOptions);

                       dispatcher.on('end', () => {
                           dispatcher = null;
                           PlayNextStreamInQueue();
                       });

                       dispatcher.on('error', (err) => {
                           console.log(err);
                       });
                   }
               } else {
                   dispatcher = bot.voiceConnections.first().playStream(stream, streamOptions);
               }
               
           }
       }

       function PlayNextStreamInQueue() {
           ytAudioQueue.splice(0, 1);

           if (ytAudioQueue.length != 0) {
               console.log("now Playing " + ytAudioQueue[0].videoName);
               PlayStream(ytAudioQueue[0].streamUrl);
           }
       }


    bot.login(config.token);

    youtube.js file

    var request = require('superagent');

    const API_KEY = "My API KEY";
    const WATCH_VIDEO_URL = "https://www.youtube.com/watch?v=";

    exports.watchVideoUrl = WATCH_VIDEO_URL;

    exports.search = function search(searchKeywords, callback) {
     var requestUrl = 'https://www.googleapis.com/youtube/v3/search' + '?part=snippet&q=' + escape(searchKeywords) + '&key=' + API_KEY;

     request(requestUrl, (error, response) => {
       if (!error && response.statusCode == 200) {

         var body = response.body;
         if (body.items.length == 0) {
           console.log("I Could Not Find Anything!");
           return;
         }
         for (var item of body.items) {
           if (item.id.kind == 'youtube#video') {
             callback(item.id.videoId, item.snippet.title);
             return;
           }
         }
       } else {
         console.log("Unexpected error!");
         return;
       }
     });

     return;

    };

    Error I am getting when I try to run code :

    Joined General

    C :\Discord Bot\node_modules\discord.js\src\client\voice\pcm\FfmpegConverterEngine.

    js:80

    throw new Error(

    ^

    Error : FFMPEG was not found on your system, so audio cannot be played. Please make
    sure FFMPEG is installed and in your PATH.