Ankündigung

Einklappen
Keine Ankündigung bisher.

Sound abspielen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    #16
    Zitat von swiss Beitrag anzeigen
    Wenn ich aber im Editor einen Relativen Pfad angebe
    Nenn bitte ein konkretes Beispiel, welche URI er nicht akzeptiert.
    Der Typ URI wird beispielsweise auch bei image-widgets für das src-Attribut verwendet - wird es da bei dir akzeptiert?

    Kommentar


      #17
      Hallo Julian

      Ich kann weder: http://192.168.1.120/visu_svn/test.ogg noch ./test.ogg als Pfad verwenden. Die Datei liegt im Hauptverzeichniss visu_svn.

      Image funktioniert hingegen problemlos auch mit relativen Pfaden.
      Gruss Patrik alias swiss

      Kommentar


        #18
        Hallo

        Also ich habe jetzt mal ein Bisschen was probiert, stosse jedoch auf Probleme.

        Das Audio Element wird irgendwie erst aktiv nachdem ich die GA mit dem Trigger ein paar mal ein und wieder ausgeschaltet habe. Wie kann das kommen? könnt ihr das nachvollziehen?

        Dann weis ich nicht wie ich das audio element ansprechen kann.
        Ich möchte dort wo alert('play'); / alert('play'); steht eigentlich das auddio mit .play() und .pause() starten resp. anhalten.
        Ich weis jedoch nicht wie ich vom "element" zum audio komme.

        Die Alerts erscheinen, also das Widget reagiert korrekt auf die statusänderungen der GA.

        Ich teste mit Chrome auf einem Windows 7 Client.

        Das Widget:
        PHP-Code:
        VisuDesign_Custom.prototype.addCreator('audio', {
          
        create: function( elementpathflavourtype ) {
            var 
        $e = $(element);
            var 
        layout $e.children('layout')[0];
            var 
        style layout 'style="' extractLayoutlayouttype ) + '"' '';
            var 
        ret_val = $('<div class="widget clearfix video" ' style '/>');
            
        ret_val.setWidgetLayout($e);
            if( 
        $e.attr('flavour') ) flavour $e.attr('flavour');// sub design choice
            
        if( flavour ret_val.addClass'flavour_' flavour );
            
        ret_val.appendextractLabel$e.find('label')[0] ) );
            var 
        autoplay = ($e.attr('autoplay') && $e.attr('autoplay')=='true') ? ' autoplay="autoplay"' '';
            var 
        style '';
            if( 
        $e.attr('width' ) ) style += 'width:'  $e.attr('width' ) + ';';
            if( 
        $e.attr('height') ) style += 'height:' $e.attr('height') + ';';
            if( 
        style != '' style 'style="' style '"';
         
         var 
        address makeAddressList($e);
         
            var 
        actor '<div class="actor"><audio src="' +$e.attr('src') + '" ' style autoplay '  controls="controls" /></div>';
         var 
        $actor = $(actor).data( {
              
        'address' address,
              
        /*'mapping' : $e.attr('mapping'),
              'styling' : $e.attr('styling'),
              'on_value'  : $e.attr('on_value' ) || 1,
              'off_value' : $e.attr('off_value') || 0,
              'align'   : $e.attr('align'),*/
              
        'type'    'audio',
           
        'firstrun'    :  true
            
        } );
         for( var 
        addr in address 
            { 
              if( 
        address[addr][1] & $actor.bindaddrthis.update ); // only when read flag is set
            
        }
            
        ret_val.append( $(actor).data( {} ) );
            return 
        ret_val;
          },
          
        update: function(e,d) { 
            var 
        element = $(this);
         
        element.load()
            var 
        value defaultUpdateedelement );
         
         
        // if not the first run
         
        if (!element.data'firstrun' )){
          if (
        value == true) {
           
        alert('play');
          } else {
           
        alert('pause');
          }
         
         } else {
          
        element.data'firstrun'false );
         }
           
        /*
            var off = map( element.data( 'off_value' ), element.data('mapping') );
            element.removeClass( value == off ? 'switchPressed' : 'switchUnpressed' );
            element.addClass(    value == off ? 'switchUnpressed' : 'switchPressed' );
         */
          
        }
        }); 
        Config:
        HTML-Code:
         <page name="Test" visible="false">
           <switch mapping="OnOff" styling="GreyYellow">
                    <label><icon name="audio_play" />Play</label>
                    <address transform="DPT:1.001" mode="readwrite" variant="">11/2/6</address>
                  </switch>
           <audio src="media\test.mp3">
          <address transform="DPT:1.001" mode="read" variant="">11/2/6</address>
           </audio>
            </page>

        Kommentar


          #19
          Hallo Zusammen

          Hm... keiner eine Idee?

          Iwan

          Kommentar


            #20
            Sound abspielen

            Wie ist hier eigentlich der aktuelle Stand?! Gerade ein Sound on GA würde mich interessieren. Dabei wäre noch zu überlegen, ob man mittels eines Parameters die Wiederholungsfrequenz definieren kann - also sowas die "Play 1x" oder "Play 1x pro Minute".

            Ist denn Deine Version des Sound Plugins denn im SVN?

            Gruß, netsrac

            Kommentar


              #21
              Hallo

              Da hat sich nichts geändert, hatte schlichtweg keine Zeit.
              Ist halt wie bei vielen anderen, die Ideen wären da aber keine Change das alles umzusetzen,
              resp. geht es meistens nicht über die Idee oder den Prototyp hinaus...
              Nein ist nicht im SVN, gibt nur das im obigen Beitrag.

              Iwan

              Kommentar


                #22
                Hallo zusammen

                Ich möchte auch gerne über meine Visu eine Audio Datei abspielen. Wie ist der aktuelle Stand? Wurde an diesem Feature noch gearbeitet oder gibt es unterdessen eine andere Möglichkeit?

                Ansonsten würde ich von meiner Seite her einen Versuch starten die noch bestehenden Probleme zu lösen.

                Gruss, Markus

                Kommentar


                  #23
                  Hallo Markus

                  Soweit ich weiss, hat sich in diese Richtung leider nichts mehr getan. Wenn du die nötigen Fähigkeiten besitzt um die angedachte Idee in ein fertiges CV Plugin umzusezen wäre dies natürlich toll
                  Gruss Patrik alias swiss

                  Kommentar


                    #24
                    Hallo zusammen

                    Ich habe nun meine Version fertig. Getestet habe ich noch nicht gross. Also wenn jemand Zeit hat ;-)

                    Folgende Feature habe ich realisiert:
                    • autoplay = true : spielt die Musikdatei beim ersten öffnen ab
                    • loop = true : spielt die Musikdatei im loop ab
                    • on_value = 1 und off_value = 0 : in Verbindung mit einer addresse DPT 1.001 wird beim Empfangen von einer 1 die Musikdatei abgespielt. Bei 0 passiert nichts. Dies kann natürlich auch anderst gemapped werden.
                    • volume funktioniert noch nicht!
                    • src : habe ich mit relativem Pfad sowohl einer wav und einer mp3 Datei getestet.
                    • id: eine beliebige Kennzeichnung (text) zur Identifizierung von verschiedenen audio Elementen.

                    Die Änderungen sind noch nicht im svn. Hier ist der manuelle Weg für die Installation:


                    In ./structure/pure/ ein audio.js Datei erstellen mit folgendem Inhalt:
                    Code:
                    /* audio.js (c) 2014 by Markus Damman
                     *
                     * This program is free software; you can redistribute it and/or modify it
                     * under the terms of the GNU General Public License as published by the Free
                     * Software Foundation; either version 3 of the License, or (at your option)
                     * any later version.
                     *
                     * This program is distributed in the hope that it will be useful, but WITHOUT
                     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
                     * more details.
                     *
                     * You should have received a copy of the GNU General Public License along
                     * with this program; if not, write to the Free Software Foundation, Inc.,
                     * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
                     */
                    
                    basicdesign.addCreator('audio', {
                      create: function( element, path, flavour, type ) {
                        var $e = $(element);
                    
                        // create the main structure
                        var ret_val = basicdesign.createDefaultWidget( 'audio', $e, path, flavour, type, this.update);
                        // and fill in widget specific data
                        ret_val.data( {
                          'src'     : $e.attr('src'),
                          'id'      : $e.attr('id'),
                          'width'   : $e.attr('with'),
                          'height'  : $e.attr('height'),
                          'autoplay': $e.attr('autoplay'),
                          'loop'    : $e.attr('loop'),
                          'on_value'  : $e.attr('on_value' ) || 1,
                          'off_value' : $e.attr('off_value') || 0
                        } );
                        var data = ret_val.data();
                    
                        // create the actor
                        var style = '';
                        if( data.width  ) style += 'width:'  + data.width  + ';';
                        if( data.height ) style += 'height:' + data.height + ';';
                        if( style != '' ) style = 'style="' + style + '"';
                        var autoplay = (data.autoplay == 'true') ? ' autoplay ' : '';
                        var loop = (data.loop == 'true') ? ' loop ' : '';
                        var $actor = $('<div class="actor"><audio id="' + $e.attr('id') + '" ' + autoplay + loop + ' controls> <source src="' +$e.attr('src') + '" > </audio> </div>');
                        ret_val.append( $actor );
                    
                        // initially setting a value
                        basicdesign.defaultUpdate(undefined, undefined, ret_val, true);
                    
                        return ret_val;
                      },
                    
                      update: function(e,d) {
                        var element = $(this);
                        var actor   = element.find('.actor');
                        var value = basicdesign.defaultUpdate( e, d, element, true );
                        var on = templateEngine.map( element.data( 'on_value' ), element.data('mapping') );
                        if (value == on){
                            var audioWidget = document.getElementById(element.data('id'));
                            if (audioWidget.paused == true)
                               audioWidget.play();
                        };
                      }
                    });
                    In der visu_config.xsd unter <xsd:group name="Widgets"> folgendes ergänzen:
                    Code:
                    <xsd:element name="audio" type="audio" />
                    Dann noch vor dem video Widget folgendes neu hinzufügen:
                    Code:
                      <xsd:complexType name="audio">
                        <xsd:sequence>
                          <xsd:element name="layout" type="layout" minOccurs="0" maxOccurs="1" />
                          <xsd:element name="label" type="label" maxOccurs="1" />
                          <xsd:element name="address" type="address" minOccurs="0" maxOccurs="unbounded"/>
                        </xsd:sequence>
                        <xsd:attribute name="src" type="uri" use="required" />
                        <xsd:attribute name="id" type="xsd:string" use="required" />
                        <xsd:attribute name="on_value" type="xsd:string" use="optional" />
                        <xsd:attribute name="off_value" type="xsd:string" use="optional" />
                        <xsd:attribute name="width" type="dimension" />
                        <xsd:attribute name="height" type="dimension" />
                        <xsd:attribute name="volume" type="xsd:string" />
                        <xsd:attribute name="autoplay" type="xsd:string" />
                        <xsd:attribute name="loop" type="xsd:string" />
                        <xsd:attribute ref="flavour" use="optional" />
                      </xsd:complexType>
                    Als letzten Schritt in die index.html vor dem video.js Eintrag folgendes einfügen:
                    Code:
                     ScriptsToInclude.push( "structure/pure/audio.js" );
                    Vielen Dank an swiss und iwan für die super Vorarbeit :-)

                    Falls die Tests gut verlaufen kann ich die Änderungen auch ins svn einchecken, sofern ich die Rechte habe.

                    Gruss, Markus

                    Kommentar


                      #25
                      Hallo Markus

                      Echt cool was du in der kurzen Zeit geschafft hast. Respekt! Das Ergebniss werde ich morgen gleich mal intensiv testen
                      Gruss Patrik alias swiss

                      Kommentar


                        #26
                        Hallo Swiss

                        Dank deiner guten Beschreibung konnte ich mich zum Glück leicht einarbeiten. Ich habe übrigens nur den Use Case für eine Alarmmeldung implementiert. Sobald ein regelmässig gesendeter Event von 0 auf 1 ändert wird bei jedem eintreffen eines 1 der Alarm Ton abgespielt und erst wieder bendet, wenn keine 1 mehr Empfangen werden.

                        Klüger wäre vermutlich einfach nur einen Schwellwert zu realisieren threshold_value >= Schwellwert => Alarm und eine Unterdrückung supress_value = 1 welche den Benützer den Alarm akzeptieren lässt.

                        Daher hier noch die Änderungen für das audio.js:
                        Code:
                        /* audio.js (c) 2014 by Markus Damman
                         *
                         * This program is free software; you can redistribute it and/or modify it
                         * under the terms of the GNU General Public License as published by the Free
                         * Software Foundation; either version 3 of the License, or (at your option)
                         * any later version.
                         *
                         * This program is distributed in the hope that it will be useful, but WITHOUT
                         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
                         * more details.
                         *
                         * You should have received a copy of the GNU General Public License along
                         * with this program; if not, write to the Free Software Foundation, Inc.,
                         * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
                         */
                        
                        basicdesign.addCreator('audio', {
                          create: function( element, path, flavour, type ) {
                            var $e = $(element);
                        
                            // create the main structure
                            var ret_val = basicdesign.createDefaultWidget( 'audio', $e, path, flavour, type, this.update);
                            // and fill in widget specific data
                            ret_val.data( {
                              'src'     : $e.attr('src'),
                              'id'      : $e.attr('id'),
                              'width'   : $e.attr('with'),
                              'height'  : $e.attr('height'),
                              'autoplay': $e.attr('autoplay'),
                              'loop'    : $e.attr('loop'),
                              'threshold_value'  : $e.attr('threshold_value' ) || 1
                            } );
                            var data = ret_val.data();
                        
                            // create the actor
                            var style = '';
                            if( data.width  ) style += 'width:'  + data.width  + ';';
                            if( data.height ) style += 'height:' + data.height + ';';
                            if( style != '' ) style = 'style="' + style + '"';
                            var autoplay = (data.autoplay == 'true') ? ' autoplay ' : '';
                            var loop = (data.loop == 'true') ? ' loop ' : '';
                            var $actor = $('<div class="actor"><audio id="' + $e.attr('id') + '" ' + autoplay + loop + ' controls> <source src="' +$e.attr('src') + '" > </audio> </div>');
                            ret_val.append( $actor );
                        
                            // initially setting a value
                            basicdesign.defaultUpdate(undefined, undefined, ret_val, true);
                        
                            return ret_val;
                          },
                        
                          update: function(e,d) {
                            var element = $(this);
                            var actor   = element.find('.actor');
                            var value = basicdesign.defaultUpdate( e, d, element, true );
                            var on = templateEngine.map( element.data( 'threshold_value' ), element.data('mapping') );
                            if (value >= on){
                                var audioWidget = document.getElementById(element.data('id'));
                                if (audioWidget.paused == true)
                                   audioWidget.play();
                            };
                          }
                        });
                        und im config.xsd
                        Code:
                          <xsd:complexType name="audio">
                            <xsd:sequence>
                              <xsd:element name="layout" type="layout" minOccurs="0" maxOccurs="1" />
                              <xsd:element name="label" type="label" maxOccurs="1" />
                              <xsd:element name="address" type="address" minOccurs="0" maxOccurs="unbounded"/>
                            </xsd:sequence>
                            <xsd:attribute name="src" type="uri" use="required" />
                            <xsd:attribute name="id" type="xsd:string" use="required" />
                            <xsd:attribute name="threshold_value" type="xsd:string" use="optional" />
                            <xsd:attribute name="width" type="dimension" />
                            <xsd:attribute name="height" type="dimension" />
                            <xsd:attribute name="volume" type="xsd:string" />
                            <xsd:attribute name="autoplay" type="xsd:string" />
                            <xsd:attribute name="loop" type="xsd:string" />
                            <xsd:attribute ref="flavour" use="optional" />
                          </xsd:complexType>
                        Eine Unterdrückung ist noch nicht realisiert, da ich nicht sicher bin ob es überhaupt Sinn macht. Soll ich auch noch ein attribute implementieren, welches den threshold_value umkehrt? Dies würde dann beim Unterschreiten des threshold_value den Alarm auslösen.

                        Gruss, Markus

                        Kommentar


                          #27
                          Hallo

                          Ein schönes Plugin, Herzlichen Glückwunsch.

                          Ich würde vorschlagen daraus ein Plugin zu machen.
                          Hätte den Vorteil das es nur geladen wird, wenn es in config.xml unter plugins eingetragen ist.

                          Gruß NetFritz
                          KNX & Wago 750-849 ,Wiregate u. Cometvisu, iPad 3G 64GB.
                          WP Alpha-Innotec WWC130HX (RS232-Moxa-LAN),Solaranlage für Brauchwasser und Heizung.
                          PV-Anlage = SMA Webbox2.0 , SunnyBoy 4000TL, Sharp 4kWP

                          Kommentar


                            #28
                            Hallo NetFritz

                            Vielen Dank.

                            Da es reines HTML 5 ist bin ich nicht sicher ob sich ein Plugin lohnt. So oder so müsste dann auch das bestehende Video Element genau gleich gestaltet werden. Eine Überarbeitung würde diesem Element auf jeden Fall gut tun ;-) Es ist ein wenig in die Jahre gekommen.

                            Gruss, Markus

                            Kommentar


                              #29
                              Hallo zusammen

                              Im Style attribute hat es noch zwei Fehler gehabt. Hier ist die Korrektur:

                              Code:
                              /* audio.js (c) 2014 by Markus Damman
                               *
                               * This program is free software; you can redistribute it and/or modify it
                               * under the terms of the GNU General Public License as published by the Free
                               * Software Foundation; either version 3 of the License, or (at your option)
                               * any later version.
                               *
                               * This program is distributed in the hope that it will be useful, but WITHOUT
                               * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                               * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
                               * more details.
                               *
                               * You should have received a copy of the GNU General Public License along
                               * with this program; if not, write to the Free Software Foundation, Inc.,
                               * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
                               */
                              
                              basicdesign.addCreator('audio', {
                                create: function( element, path, flavour, type ) {
                                  var $e = $(element);
                              
                                  // create the main structure
                                  var ret_val = basicdesign.createDefaultWidget( 'audio', $e, path, flavour, type, this.update);
                                  // and fill in widget specific data
                                  ret_val.data( {
                                    'src'     : $e.attr('src'),
                                    'id'      : $e.attr('id'),
                                    'width'   : $e.attr('width'),
                                    'height'  : $e.attr('height'),
                                    'autoplay': $e.attr('autoplay'),
                                    'loop'    : $e.attr('loop'),
                                    'threshold_value'  : $e.attr('threshold_value' ) || 1
                                  } );
                                  var data = ret_val.data();
                              
                                  // create the actor
                                  var style = '';
                                  if( data.width  ) style += 'width:'  + data.width  + ';';
                                  if( data.height ) style += 'height:' + data.height + ';';
                                  if( style != '' ) style = 'style="' + style + '"';
                                  var autoplay = (data.autoplay == 'true') ? ' autoplay ' : '';
                                  var loop = (data.loop == 'true') ? ' loop ' : '';
                                  var $actor = $('<div class="actor"><audio id="' + $e.attr('id') + '" ' + autoplay + loop + style + ' controls> <source src="' +$e.attr('src') + '" > </audio> </div>');
                                  ret_val.append( $actor );
                              
                                  // initially setting a value
                                  basicdesign.defaultUpdate(undefined, undefined, ret_val, true);
                              
                                  return ret_val;
                                },
                              
                                update: function(e,d) {
                                  var element = $(this);
                                  var actor   = element.find('.actor');
                                  var value = basicdesign.defaultUpdate( e, d, element, true );
                                  var on = templateEngine.map( element.data( 'threshold_value' ), element.data('mapping') );
                                  if (value >= on){
                                      var audioWidget = document.getElementById(element.data('id'));
                                      if (audioWidget.paused == true)
                                         audioWidget.play();
                                  };
                                }
                              });
                              Stoppen kann man eine Alarmmeldung durch Stummschalten. Ich werde also nichts mehr besonderes dazu implementieren.

                              Ich habe auch noch mehrere verschiedene Sound Objekte getestet und auch die Überwachung von drei VOC Sensoren über ein Sound Element getestet. Scheint alles zu funktionieren.

                              Gruss, Markus

                              Kommentar


                                #30
                                Sehr schön! (Auch wenn von mir nicht getestet - aber das muss es ja auch nicht )
                                Zitat von Bubo Beitrag anzeigen
                                Klüger wäre vermutlich einfach nur einen Schwellwert zu realisieren threshold_value >= Schwellwert => Alarm und eine Unterdrückung supress_value = 1 welche den Benützer den Alarm akzeptieren lässt.
                                Hier bitte aufpassen. Eine Visu ist keine Logik Engine. Und gerade Themen wie Schwellwert gehören eher in eine Logik Engine...
                                => Bei diesem Feature bitte bewusst eine Grenze der Funktion ziehen
                                Zitat von Bubo Beitrag anzeigen
                                Da es reines HTML 5 ist bin ich nicht sicher ob sich ein Plugin lohnt.
                                Das ist so klein und braucht v.a. keine weiteren Ressourcen von daher sehe ich das auch eher als Widget und nicht als Plugin.

                                Ich würde vorschlagen Du commitest das in's SVN. Dann können das weitere Leute sehr einfach testen und es kann bis zum nächsten Release wunderbar reifen.
                                TS2, B.IQ, DALI, WireGate für 1wire so wie Server für Logik und als KNX Visu die CometVisu auf HomeCockpit Minor. - Bitte keine PNs, Fragen gehören in das Forum, damit jeder was von den Antworten hat!

                                Kommentar

                                Lädt...
                                X