Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MartinB 411 posts 512 karma points
    Apr 06, 2013 @ 15:51
    MartinB
    0

    UmbracoFile variable value in javascript

    Hello

    Found a jPlayer audio package in the projects section, everything works, except the mp3 reference:

    $(document).ready(function(){
    
      $("#<xsl:value-of select="concat('audioPlayer',$currentPage/@id)"/>").jPlayer({
        ready: function (event) {
          $(this).jPlayer("setMedia", {
        mp3:"<xsl:value-of select="$audioFile//umbracoFile"/>"
          });
        },
        swfPath: "/scripts/jplayer",
        supplied: "mp3",
        wmode: "window"
    
    
    });

    The mp3 value returns empty and since I didn't make this I wonder if it ever worked? Full XSLT is here:

    <xsl:param name="currentPage"/>
    <xsl:param name="audioFile" select="/macro/AudioFile"/>
    
    <xsl:template match="/">
    
      <xsl:if test="string-length($audioFile) > 0">   
    
      <div id="{concat('audioPlayer',$currentPage/@id)}"><xsl:value-of select="string(' ')"/></div>
      <div class="jp-audio" id="jp_container_1">
          <div class="jp-type-single">
            <div class="jp-gui jp-interface">
              <ul class="jp-controls">
                <li><a tabindex="1" class="jp-play" href="javascript:;">play</a></li>
                <li><a tabindex="1" class="jp-pause" href="javascript:;">pause</a></li>
                <li><a tabindex="1" class="jp-stop" href="javascript:;">stop</a></li>
                <li><a title="mute" tabindex="1" class="jp-mute" href="javascript:;">mute</a></li>
                <li><a title="unmute" tabindex="1" class="jp-unmute" href="javascript:;">unmute</a></li>
                <li><a title="max volume" tabindex="1" class="jp-volume-max" href="javascript:;">max volume</a></li>
              </ul>
              <div class="jp-progress">
                <div class="jp-seek-bar">
                  <div class="jp-play-bar"><xsl:value-of select="string(' ')"/></div>
                </div>
              </div>
              <div class="jp-volume-bar">
                <div class="jp-volume-bar-value"><xsl:value-of select="string(' ')"/></div>
              </div>
              <div class="jp-time-holder">
                <div class="jp-current-time"><xsl:value-of select="string(' ')"/></div>
                <div class="jp-duration"><xsl:value-of select="string(' ')"/></div>
    
                <ul class="jp-toggles">
                  <li><a title="repeat" tabindex="1" class="jp-repeat" href="javascript:;">repeat</a></li>
                  <li><a title="repeat off" tabindex="1" class="jp-repeat-off" href="javascript:;">repeat off</a></li>
                </ul>
              </div>
            </div>
            <div class="jp-title">
              <ul>
                <li><xsl:value-of select="$audioFile//@nodeName"/></li>
              </ul>
            </div>
            <div class="jp-no-solution">
              <span>Update Required</span>
              To play the media you will need to either update your browser to a recent version or update your <a target="_blank" href="http://get.adobe.com/flashplayer/">Flash plugin</a>.
            </div>
          </div>
        </div>
    
      <script type="text/javascript">
    
    $(document).ready(function(){
    
      $("#<xsl:value-of select="concat('audioPlayer',$currentPage/@id)"/>").jPlayer({
        ready: function (event) {
          $(this).jPlayer("setMedia", {
        mp3:"<xsl:value-of select="$audioFile//umbracoFile"/>"
          });
        },
        swfPath: "/scripts/jplayer",
        supplied: "mp3",
        wmode: "window"
    
    
    });
    
    
    });
    </script>
      </xsl:if>
    </xsl:template>

    If I use value-of select="$audioFile" i get the file path+filesize etc., so that doesn't work.

    Also I wonder why $audioFile//@nodeName works but $audioFile//umbracoFile does not.

    The question is:

    Is there a way to one-line the umbracoFile value of $audioFile in the javascript bit or what am I looking at here?

    Any help much appreciated!

     

  • Charles Afford 1163 posts 1709 karma points
    Apr 06, 2013 @ 22:22
    Charles Afford
    0

    Hi, could you tell me what this macro is?

    "/macro/AudioFile"

    This is what the $audioFile is being set to. Thanks Charlie :)

  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 12:16
    MartinB
    0
  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 14:09
    MartinB
    0
  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 14:28
    MartinB
    0

    Ok, I guess i have to do something like this:

    <xsl:value-ofselect="/macro/macroParam/Image/umbracoFile"/>

    As explained here: http://our.umbraco.org/forum/core/41-feedback/10539-mediaCurrent-and-Macro-container

    My problem though is that i'm not using images but MP3s - Replacing "Image" with i.e. "File" does not give me anything. How to do this for file media types?

  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 14:33
    MartinB
    0
  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 14:51
    MartinB
    0
  • MartinB 411 posts 512 karma points
    Apr 07, 2013 @ 15:26
    MartinB
    100

    For crying out loud!

    Version 4.7.0 site running old schema. This fixed it:

    mp3:"<xsl:value-of select="$audioFile/*/data[@alias='umbracoFile']"/>"

    *facepalm*

Please Sign in or register to post replies

Write your reply to:

Draft