IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

SoundManager et gestion des id de son à partir d'un XML


Sujet :

JavaScript

Vue hybride

Stalk3R SoundManager et gestion des... 11/07/2012, 09h34
Stalk3R Si c'est pas possible avec... 12/07/2012, 01h29
Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Août 2010
    Messages
    156
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 156
    Par défaut SoundManager et gestion des id de son à partir d'un XML
    Bonjour,
    Comment utiliser les ID des sons à partir de fichier XML ?

    Avec ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    soundManager.loadFromXML("acoustic-drumkit.xml");
    En d'autres termes comment l'utiliser ici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
     
    /**
     * SoundManager 2: MPC (Drum Machine) demo
     */
     
    var MPC = function() {
      var self = this;
      this.idPrefix = 'btn-'; // HTML ID prefix
      this.statusWidth = 6;
      this.progressWidth = 256;
      this.keys = {'1':0,'2':1,'3':2,'4':3,'q':4,'w':5,'e':6,'r':7,'a':8,'s':9,'d':10,'f':11,'z':12,'x':13,'c':14,'v':15}
     
      // scope within these event handler methods: "this" = SMSound() object instance (see SMSound() in soundmanager.js for reference) 
     
      this.showProgress = function() {
        // sound is loading, update bytes received using this.bytesLoaded / this.bytesTotal
        if (self._getButton(this.id).className != 'loading') self._getButton(this.id).className = 'loading'; // a bit inefficient here..
        self._showStatus(this.id,this.bytesLoaded,this.bytesTotal);
      }
     
      this.onid3 = function() {
        soundManager._writeDebug('mpc.onid3()');
        var oName = null;
        for (var oName in this.id3) {
          soundManager._writeDebug(oName+': '+this.id3[oName]) // write out name/value ID3 pairs (eg. "artist: Beck")
        }
      }
     
      this.onload = function() {
        var sID = this.id;
        self._getButton(this.id).className = '';
        self._getButton(this.id).title = ('Sound ID: '+this.id+' ('+this.url+')');
      }
     
      this.onfinish = function() {
        self._getButton(this.id).className = '';
        self._reset(this.id);
      }
     
      this.onplay = function() {
        self._getButton(this.id).className = 'active';
      }
     
      this.whileplaying = function() {
        self._showStatus(this.id,this.position,this.duration);
      }
     
      this._keyHandler = function(e) {
        var oEvt = e?e:event;
        var sChar = String.fromCharCode(oEvt.keyCode).toLowerCase();
        if (typeof self.keys[sChar] != 'undefined') soundManager.play('s'+self.keys[sChar]);
      }
     
      this._showStatus = function(sID,n1,n2) {
        var o = self._getButton(sID).getElementsByTagName('div')[0];
        var offX = (n2>0?(-self.progressWidth+parseInt((n1/n2)*o.offsetWidth)):-self.progressWidth);
        o.style.backgroundPosition = offX+'px 0px';
      }
     
      this._getButton = function(sID) {
        return document.getElementById(self.idPrefix+sID);
      }
     
      this._reset = function(sID) {
        var id = sID;
        self._showStatus(sID,1,1);
        setTimeout(function(){self._showStatus(sID,0,0);},200);
      }
     
      this.init = function() {
        document.onkeydown = self._keyHandler;
      }
     
    }
     
    var mpc = new MPC();
     
    soundManager.flashVersion = (window.location.toString().match(/#flash8/i)?8:9);
    if (soundManager.flashVersion != 8) {
      soundManager.useHighPerformance = true;
    }
     
    soundManager.setup({
      url: base_path+'/party/swf/', // path to load SWF from (overriding default)
      bgColor: '#333333',
      wmode: 'transparent',
      debugMode: false,
      consoleOnly: false,
      useFlashBlock: true
    });
     
    soundManager.onready(function() {
     
      // This is the "onload" equivalent which is called when SoundManager has been initialised (sounds can be created, etc.)
     
      mpc.init();
     
      // set up some default options / event handlers - so all sounds created are given these handlers
     
      soundManager.setup({
        defaultOptions: {
          autoLoad: true,
          whileloading: mpc.showProgress,
          onid3: mpc.onid3,
          onload: mpc.onload,
          onplay: mpc.onplay,
          whileplaying: mpc.whileplaying,
          onfinish: mpc.onfinish
        }
      });
     
      if (!soundManager.html5.needsFlash) {
        document.getElementById('isHTML5').style.display = 'inline';
      }
      var soundURLs = 'AMB_BD_1,AMB_FTM2,AMB_HHCL,AMB_HHOP,AMB_HHPD,AMB_HTM,AMB_LTM2,AMB_MTM,AMB_RIM1,AMB_SN13,AMB_SN_5,CHINA_1,CRASH_1,CRASH_5,CRASH_6,RIDE_1'.split(',');
      for (var i=0; i<soundURLs.length; i++) {
        soundManager.createSound('s'+i, base_path+'/party/audio/'+soundURLs[i]+'.mp3');
      }
     
      /**
       * createSound options can also be set on a per-file basis, with specific option overrides.
       * (Options not specified here will inherit defaults as defined in soundManager.defaultOptions.)
       *
       * eg.
       *
       * soundManager.createSound({
       *  id: 'mySound',
       *  url: '/path/to/some.mp3',
       *  stream: true,
       *  autoPlay: true,
       *  multiShot: false,
       *  whileloading: function() { alert('sound '+this.id+': '+this.bytesLoaded+' of '+this.bytesTotal+' bytes loaded.'); } // event handler: "this" is scoped to SMSound() object instance for easy access to methods/properties
       * });
       *
       * - OR -
       *
       * If you just want a sound with all default options, you can also specify just the required id and URL as string parameters:
       *
       * soundManager.createSound('mySound','/path/to/some.mp3');
       */
    });
    Sachant que j'ai utiliser le même fichier XML:
    http://www.schillmania.com/projects/...ic-drumkit.xml

    J'attend votre réponse avec impatience
    ça fait un bon moment que je cherche la solution et je l'a trouve pas sur notre amis google.

    Merci encore

  2. #2
    Membre confirmé
    Inscrit en
    Août 2010
    Messages
    156
    Détails du profil
    Informations forums :
    Inscription : Août 2010
    Messages : 156
    Par défaut
    Si c'est pas possible avec cette commande y aura-t-il d'autres manières de le faire ? merci

Discussions similaires

  1. Logiciel de gestion des harmoniques du son
    Par elodouwen dans le forum Audio
    Réponses: 0
    Dernier message: 05/08/2014, 09h00
  2. Gestion des urls de son site
    Par themostmd dans le forum Général Conception Web
    Réponses: 1
    Dernier message: 18/07/2011, 13h10
  3. Réponses: 0
    Dernier message: 30/05/2011, 16h48
  4. [PDF] gérerer des fichier PDF a partir du fichier XML
    Par dalilnet dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 27/11/2008, 16h04
  5. Gestion des sons dans un SoundManager
    Par trecks dans le forum C++
    Réponses: 2
    Dernier message: 03/11/2007, 19h35

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo