html5 set border color with javascript when playingWhen to use double or single quotes in JavaScript?How to execute a JavaScript function when I have its name as a stringSet a default parameter value for a JavaScript functionChange an HTML5 input's placeholder color with CSSUsing HTML5/Canvas/JavaScript to take in-browser screenshotsColors in JavaScript consolePlaying audio with Javascript?HTML5 Audio - Progress BarJavaScript set object key by variableFireFox have two audio when play the mp4 with HTML5

Would a "Permanence" spell in 5e be overpowered?

Is throwing dice a stochastic or a deterministic process?

Does running exec do anything?

What to do when scriptures go against conscience?

Is disk brake effectiveness mitigated by tyres losing traction under strong braking?

In Futurama, how many beings has Leela slept with?

no sense/need/point

Is any special diet an effective treatment of autism?

Is 'contemporary' ambiguous and if so is there a better word?

Looking for sci-fi book based on Hinduism/Buddhism

Is there a word for food that's gone 'bad', but is still edible?

Is there an age requirement to play in Adventurers League?

Is there a proof that the set of real numbers can exactly represent distances?

What's the 2-minute timer on mobile Deutsche Bahn tickets?

Why does sound not move through a wall?

How do I allocate more memory to an app on Sheepshaver running Mac OS 9?

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

Piano: quaver triplets in RH v dotted quaver and semiquaver in LH

My first C++ game (snake console game)

Game artist computer workstation set-up – is this overkill?

What was the first story to feature the plot "the monsters were human all along"?

Why would a military not separate its forces into different branches?

Krull dimension of the ring of global sections

Motion-trail-like lines



html5


When to use double or single quotes in JavaScript?How to execute a JavaScript function when I have its name as a stringSet a default parameter value for a JavaScript functionChange an HTML5 input's placeholder color with CSSUsing HTML5/Canvas/JavaScript to take in-browser screenshotsColors in JavaScript consolePlaying audio with Javascript?HTML5 Audio - Progress BarJavaScript set object key by variableFireFox have two audio when play the mp4 with HTML5






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















digital store with mp3 files:



  • html5 'audio' tag is used, with 'controls'; works superb

  • since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);

it is django project (python); with bootstrap 4



  • audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
    ok, crimson. lol.

html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:



  • play Fires when the audio/video has been started or is no longer paused

html:



 <div id="sample-container"
class="col-auto my-auto">
<!-- sample player -->

<!-- style="border-color:crimson" -->

<!-- onplay="player_border();" -->
<audio id="sample-player"
controls
loop
play="player_border();"
class="btn btn-sm my-auto ">
<source src=" instance.audio.url "
type="audio/mpeg">
</audio>
</div>


audio tag also has 'paused' property:



  • paused Returns whether the audio/video is paused or not

script:



 <!-- scripts -->
<script type="text/javascript">
function player_border()

var player = document.getElementById('sample-player'); // <audio>
var playContainer = document.getElementById('sample-container'); // <div>
playContainer.style.borderColor = 'orange'; // ko
player.style.borderColor = 'green'; // ko
var isPlaying = (!player.paused);
//document.getElementById("play_sample").play = function()
// elem = document.getElementById('#play_sample')
// var elem = document.getElementById('play_sample').innerHTML; # for inner text
// var player = document.getElementById('#play_sample');
// var play_container = document.getElementById('#play_container');
// play_container.style.color = 'orange;'
// play_container.style = 'border-color:orange;'
// play_container.style.borderColor = 'color:orange;'
// player.style.borderColor = 'color:green;'

// if (elem.audio.play)
// if (!elem.paused)
// if (!elem.audio.paused)
// if (!player.paused)
// if (player.play)
if (isPlaying)

playContainer.style = 'border-color:green';
player.style.borderColor = 'orange';
// player.style = 'borderColor:orange';
// play_container.style = 'border-color:border-warning'
// player.setAttribute('style', 'borderColor:orange;')
// play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
// elem.style = 'border:orange;'
// elem.setAttribute('style', 'border: 1px solid orange;'
// elem.style = 'border:border-warning'
;

</script>


say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;



sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.



thx for help,



bow,



s love nia










share|improve this question




























    0















    digital store with mp3 files:



    • html5 'audio' tag is used, with 'controls'; works superb

    • since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);

    it is django project (python); with bootstrap 4



    • audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
      ok, crimson. lol.

    html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:



    • play Fires when the audio/video has been started or is no longer paused

    html:



     <div id="sample-container"
    class="col-auto my-auto">
    <!-- sample player -->

    <!-- style="border-color:crimson" -->

    <!-- onplay="player_border();" -->
    <audio id="sample-player"
    controls
    loop
    play="player_border();"
    class="btn btn-sm my-auto ">
    <source src=" instance.audio.url "
    type="audio/mpeg">
    </audio>
    </div>


    audio tag also has 'paused' property:



    • paused Returns whether the audio/video is paused or not

    script:



     <!-- scripts -->
    <script type="text/javascript">
    function player_border()

    var player = document.getElementById('sample-player'); // <audio>
    var playContainer = document.getElementById('sample-container'); // <div>
    playContainer.style.borderColor = 'orange'; // ko
    player.style.borderColor = 'green'; // ko
    var isPlaying = (!player.paused);
    //document.getElementById("play_sample").play = function()
    // elem = document.getElementById('#play_sample')
    // var elem = document.getElementById('play_sample').innerHTML; # for inner text
    // var player = document.getElementById('#play_sample');
    // var play_container = document.getElementById('#play_container');
    // play_container.style.color = 'orange;'
    // play_container.style = 'border-color:orange;'
    // play_container.style.borderColor = 'color:orange;'
    // player.style.borderColor = 'color:green;'

    // if (elem.audio.play)
    // if (!elem.paused)
    // if (!elem.audio.paused)
    // if (!player.paused)
    // if (player.play)
    if (isPlaying)

    playContainer.style = 'border-color:green';
    player.style.borderColor = 'orange';
    // player.style = 'borderColor:orange';
    // play_container.style = 'border-color:border-warning'
    // player.setAttribute('style', 'borderColor:orange;')
    // play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
    // elem.style = 'border:orange;'
    // elem.setAttribute('style', 'border: 1px solid orange;'
    // elem.style = 'border:border-warning'
    ;

    </script>


    say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;



    sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.



    thx for help,



    bow,



    s love nia










    share|improve this question
























      0












      0








      0








      digital store with mp3 files:



      • html5 'audio' tag is used, with 'controls'; works superb

      • since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);

      it is django project (python); with bootstrap 4



      • audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
        ok, crimson. lol.

      html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:



      • play Fires when the audio/video has been started or is no longer paused

      html:



       <div id="sample-container"
      class="col-auto my-auto">
      <!-- sample player -->

      <!-- style="border-color:crimson" -->

      <!-- onplay="player_border();" -->
      <audio id="sample-player"
      controls
      loop
      play="player_border();"
      class="btn btn-sm my-auto ">
      <source src=" instance.audio.url "
      type="audio/mpeg">
      </audio>
      </div>


      audio tag also has 'paused' property:



      • paused Returns whether the audio/video is paused or not

      script:



       <!-- scripts -->
      <script type="text/javascript">
      function player_border()

      var player = document.getElementById('sample-player'); // <audio>
      var playContainer = document.getElementById('sample-container'); // <div>
      playContainer.style.borderColor = 'orange'; // ko
      player.style.borderColor = 'green'; // ko
      var isPlaying = (!player.paused);
      //document.getElementById("play_sample").play = function()
      // elem = document.getElementById('#play_sample')
      // var elem = document.getElementById('play_sample').innerHTML; # for inner text
      // var player = document.getElementById('#play_sample');
      // var play_container = document.getElementById('#play_container');
      // play_container.style.color = 'orange;'
      // play_container.style = 'border-color:orange;'
      // play_container.style.borderColor = 'color:orange;'
      // player.style.borderColor = 'color:green;'

      // if (elem.audio.play)
      // if (!elem.paused)
      // if (!elem.audio.paused)
      // if (!player.paused)
      // if (player.play)
      if (isPlaying)

      playContainer.style = 'border-color:green';
      player.style.borderColor = 'orange';
      // player.style = 'borderColor:orange';
      // play_container.style = 'border-color:border-warning'
      // player.setAttribute('style', 'borderColor:orange;')
      // play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
      // elem.style = 'border:orange;'
      // elem.setAttribute('style', 'border: 1px solid orange;'
      // elem.style = 'border:border-warning'
      ;

      </script>


      say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;



      sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.



      thx for help,



      bow,



      s love nia










      share|improve this question














      digital store with mp3 files:



      • html5 'audio' tag is used, with 'controls'; works superb

      • since there are many audios, user should be visually reminded which one is playing - i want border around audio that is playing (active);

      it is django project (python); with bootstrap 4



      • audio tag does not support styling, but it is possible to render orange border using: 'style="border-color:crimson"' in audio tag.
        ok, crimson. lol.

      html5 audio tag has 'play' event, it should be triggered when audio is played, by clicking 'play' on player:



      • play Fires when the audio/video has been started or is no longer paused

      html:



       <div id="sample-container"
      class="col-auto my-auto">
      <!-- sample player -->

      <!-- style="border-color:crimson" -->

      <!-- onplay="player_border();" -->
      <audio id="sample-player"
      controls
      loop
      play="player_border();"
      class="btn btn-sm my-auto ">
      <source src=" instance.audio.url "
      type="audio/mpeg">
      </audio>
      </div>


      audio tag also has 'paused' property:



      • paused Returns whether the audio/video is paused or not

      script:



       <!-- scripts -->
      <script type="text/javascript">
      function player_border()

      var player = document.getElementById('sample-player'); // <audio>
      var playContainer = document.getElementById('sample-container'); // <div>
      playContainer.style.borderColor = 'orange'; // ko
      player.style.borderColor = 'green'; // ko
      var isPlaying = (!player.paused);
      //document.getElementById("play_sample").play = function()
      // elem = document.getElementById('#play_sample')
      // var elem = document.getElementById('play_sample').innerHTML; # for inner text
      // var player = document.getElementById('#play_sample');
      // var play_container = document.getElementById('#play_container');
      // play_container.style.color = 'orange;'
      // play_container.style = 'border-color:orange;'
      // play_container.style.borderColor = 'color:orange;'
      // player.style.borderColor = 'color:green;'

      // if (elem.audio.play)
      // if (!elem.paused)
      // if (!elem.audio.paused)
      // if (!player.paused)
      // if (player.play)
      if (isPlaying)

      playContainer.style = 'border-color:green';
      player.style.borderColor = 'orange';
      // player.style = 'borderColor:orange';
      // play_container.style = 'border-color:border-warning'
      // player.setAttribute('style', 'borderColor:orange;')
      // play_container.setAttribute('style', 'color:orange; border: 1px solid blue;')
      // elem.style = 'border:orange;'
      // elem.setAttribute('style', 'border: 1px solid orange;'
      // elem.style = 'border:border-warning'
      ;

      </script>


      say "i expect" when audio tag control (play audio) is clicked, and audio (mp3) is playing, there should be colored border around audio player, since it is possible to render colored border around audio player;



      sad reality, which does not necessary implies a lack of intelligence (lol), is that i am solving this for 8 hours straight; obviously a newbie with js and html5 audio tag.



      thx for help,



      bow,



      s love nia







      javascript html5 audio border






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 2:50









      chistabochistabo

      34




      34






















          3 Answers
          3






          active

          oldest

          votes


















          0














          Event listeners in HTML start with the on prefix



          Your code is correct, however, you need to use the attribute onplay not play



          <audio onplay="callYourFunc()"></audio>


          Another note:



          You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.






          share|improve this answer























          • yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

            – chistabo
            Mar 23 at 3:22











          • Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

            – ChrisBrownie55
            Mar 23 at 3:25











          • ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

            – chistabo
            Mar 23 at 3:35












          • Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

            – ChrisBrownie55
            Mar 23 at 3:39











          • lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

            – chistabo
            Mar 23 at 3:55



















          0














          this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.



           <div id="sample-container"
          class="col-auto my-auto">
          <!-- sample player -->
          <!-- style="border-color:crimson" -->
          <!-- play="player_border();" -->
          <!-- style="background:crimson; border-radius:27px;" -->
          <audio id="sample-player"
          controls
          loop
          onplay="sample_play();"
          onpause="sample_pause()"
          class="btn btn-sm my-auto">
          <source src=" instance.audio.url "
          type="audio/mpeg">
          </audio>
          </div>
          <div class="col-auto my-auto">
          <span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
          </div>
          </div>
          <!-- song description -->
          <div class="row my-auto pb-2 text-justify">
          <span class="text my-auto"> instance.description </span>
          </div>
          <!-- scripts -->
          <script type="text/javascript">
          function sample_play()

          var player = document.getElementById('sample-player'); // <audio>
          var playContainer = document.getElementById('sample-container'); // <div>
          var isPlaying = (!player.paused);
          if (isPlaying)

          player.style = 'background:crimson; border-radius:27px';
          ;


          function sample_pause()

          var player = document.getElementById('sample-player'); // <audio>
          var playContainer = document.getElementById('sample-container'); // <div>
          var isPlaying = (!player.paused);
          if (!isPlaying)

          player.style = 'background:none; border-radius:27px';


          </script>


          thx for help, i need somebody, help, not just anybody, lol, beatles.
          this is the main loop (django/python) that populates items on page, it is in another file:



           % for obj in object_list %
          <div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
          <div class="col my-auto ">
          % include 'products/snippets/card.html' with instance=obj %
          </div>
          </div>
          % endfor %


          what now?






          share|improve this answer






























            0














            making slow progress:
            audio tag has two events, same function call:



             onplay="sample_play()"
            onpause="sample_play()"


            function sample_play() has been simplified:



             <script type="text/javascript">
            function sample_play()

            var player = document.getElementById('sample-player')
            if (!player.paused)

            player.style = 'background:crimson; border-radius:27px'

            else

            player.style = 'background:none; border-radius:27px'


            </script>


            but, still, it only works on first audio element on page. weird, i say.
            thx for help.






            share|improve this answer























            • i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

              – chistabo
              Mar 23 at 5:12











            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310157%2fhtml5-audio-set-border-color-with-javascript-when-playing%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Event listeners in HTML start with the on prefix



            Your code is correct, however, you need to use the attribute onplay not play



            <audio onplay="callYourFunc()"></audio>


            Another note:



            You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.






            share|improve this answer























            • yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

              – chistabo
              Mar 23 at 3:22











            • Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

              – ChrisBrownie55
              Mar 23 at 3:25











            • ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

              – chistabo
              Mar 23 at 3:35












            • Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

              – ChrisBrownie55
              Mar 23 at 3:39











            • lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

              – chistabo
              Mar 23 at 3:55
















            0














            Event listeners in HTML start with the on prefix



            Your code is correct, however, you need to use the attribute onplay not play



            <audio onplay="callYourFunc()"></audio>


            Another note:



            You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.






            share|improve this answer























            • yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

              – chistabo
              Mar 23 at 3:22











            • Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

              – ChrisBrownie55
              Mar 23 at 3:25











            • ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

              – chistabo
              Mar 23 at 3:35












            • Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

              – ChrisBrownie55
              Mar 23 at 3:39











            • lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

              – chistabo
              Mar 23 at 3:55














            0












            0








            0







            Event listeners in HTML start with the on prefix



            Your code is correct, however, you need to use the attribute onplay not play



            <audio onplay="callYourFunc()"></audio>


            Another note:



            You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.






            share|improve this answer













            Event listeners in HTML start with the on prefix



            Your code is correct, however, you need to use the attribute onplay not play



            <audio onplay="callYourFunc()"></audio>


            Another note:



            You may want to listen for the pause event via onpause="callYourFunc()" to remove the style when the <audio> element has paused.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 23 at 2:57









            ChrisBrownie55ChrisBrownie55

            2,0071823




            2,0071823












            • yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

              – chistabo
              Mar 23 at 3:22











            • Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

              – ChrisBrownie55
              Mar 23 at 3:25











            • ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

              – chistabo
              Mar 23 at 3:35












            • Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

              – ChrisBrownie55
              Mar 23 at 3:39











            • lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

              – chistabo
              Mar 23 at 3:55


















            • yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

              – chistabo
              Mar 23 at 3:22











            • Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

              – ChrisBrownie55
              Mar 23 at 3:25











            • ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

              – chistabo
              Mar 23 at 3:35












            • Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

              – ChrisBrownie55
              Mar 23 at 3:39











            • lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

              – chistabo
              Mar 23 at 3:55

















            yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

            – chistabo
            Mar 23 at 3:22





            yes, i have tried 'onplay...' also (commented row above 'div'), it is not working as expected. also, the script as it is now, it should render a border around audio player, and around its parent container (test) - when audio is played. thx for the 'onpause' tip. first must solve 'onplay' mystery. lol

            – chistabo
            Mar 23 at 3:22













            Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

            – ChrisBrownie55
            Mar 23 at 3:25





            Does the function player_border ever run? Try placing a console.log('test') or debugger; at the top to see if it hits that point

            – ChrisBrownie55
            Mar 23 at 3:25













            ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

            – chistabo
            Mar 23 at 3:35






            ok, 'onplay' actually works, but politically incorrect: i have not noticed whole day, the code works on first item on page, none of the rest items is effected. 9 items currently. and it stays bordered, as i have to implement 'onpause'. off i go.

            – chistabo
            Mar 23 at 3:35














            Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

            – ChrisBrownie55
            Mar 23 at 3:39





            Okay, well @Chistabo, if this answer helped you don't forget to upvote it and/or mark it as the answer.

            – ChrisBrownie55
            Mar 23 at 3:39













            lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

            – chistabo
            Mar 23 at 3:55






            lol, i dont have enough reputation to upvote. tried. failed. lol. the mystery is not solved yet. thx for help.

            – chistabo
            Mar 23 at 3:55














            0














            this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.



             <div id="sample-container"
            class="col-auto my-auto">
            <!-- sample player -->
            <!-- style="border-color:crimson" -->
            <!-- play="player_border();" -->
            <!-- style="background:crimson; border-radius:27px;" -->
            <audio id="sample-player"
            controls
            loop
            onplay="sample_play();"
            onpause="sample_pause()"
            class="btn btn-sm my-auto">
            <source src=" instance.audio.url "
            type="audio/mpeg">
            </audio>
            </div>
            <div class="col-auto my-auto">
            <span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
            </div>
            </div>
            <!-- song description -->
            <div class="row my-auto pb-2 text-justify">
            <span class="text my-auto"> instance.description </span>
            </div>
            <!-- scripts -->
            <script type="text/javascript">
            function sample_play()

            var player = document.getElementById('sample-player'); // <audio>
            var playContainer = document.getElementById('sample-container'); // <div>
            var isPlaying = (!player.paused);
            if (isPlaying)

            player.style = 'background:crimson; border-radius:27px';
            ;


            function sample_pause()

            var player = document.getElementById('sample-player'); // <audio>
            var playContainer = document.getElementById('sample-container'); // <div>
            var isPlaying = (!player.paused);
            if (!isPlaying)

            player.style = 'background:none; border-radius:27px';


            </script>


            thx for help, i need somebody, help, not just anybody, lol, beatles.
            this is the main loop (django/python) that populates items on page, it is in another file:



             % for obj in object_list %
            <div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
            <div class="col my-auto ">
            % include 'products/snippets/card.html' with instance=obj %
            </div>
            </div>
            % endfor %


            what now?






            share|improve this answer



























              0














              this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.



               <div id="sample-container"
              class="col-auto my-auto">
              <!-- sample player -->
              <!-- style="border-color:crimson" -->
              <!-- play="player_border();" -->
              <!-- style="background:crimson; border-radius:27px;" -->
              <audio id="sample-player"
              controls
              loop
              onplay="sample_play();"
              onpause="sample_pause()"
              class="btn btn-sm my-auto">
              <source src=" instance.audio.url "
              type="audio/mpeg">
              </audio>
              </div>
              <div class="col-auto my-auto">
              <span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
              </div>
              </div>
              <!-- song description -->
              <div class="row my-auto pb-2 text-justify">
              <span class="text my-auto"> instance.description </span>
              </div>
              <!-- scripts -->
              <script type="text/javascript">
              function sample_play()

              var player = document.getElementById('sample-player'); // <audio>
              var playContainer = document.getElementById('sample-container'); // <div>
              var isPlaying = (!player.paused);
              if (isPlaying)

              player.style = 'background:crimson; border-radius:27px';
              ;


              function sample_pause()

              var player = document.getElementById('sample-player'); // <audio>
              var playContainer = document.getElementById('sample-container'); // <div>
              var isPlaying = (!player.paused);
              if (!isPlaying)

              player.style = 'background:none; border-radius:27px';


              </script>


              thx for help, i need somebody, help, not just anybody, lol, beatles.
              this is the main loop (django/python) that populates items on page, it is in another file:



               % for obj in object_list %
              <div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
              <div class="col my-auto ">
              % include 'products/snippets/card.html' with instance=obj %
              </div>
              </div>
              % endfor %


              what now?






              share|improve this answer

























                0












                0








                0







                this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.



                 <div id="sample-container"
                class="col-auto my-auto">
                <!-- sample player -->
                <!-- style="border-color:crimson" -->
                <!-- play="player_border();" -->
                <!-- style="background:crimson; border-radius:27px;" -->
                <audio id="sample-player"
                controls
                loop
                onplay="sample_play();"
                onpause="sample_pause()"
                class="btn btn-sm my-auto">
                <source src=" instance.audio.url "
                type="audio/mpeg">
                </audio>
                </div>
                <div class="col-auto my-auto">
                <span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
                </div>
                </div>
                <!-- song description -->
                <div class="row my-auto pb-2 text-justify">
                <span class="text my-auto"> instance.description </span>
                </div>
                <!-- scripts -->
                <script type="text/javascript">
                function sample_play()

                var player = document.getElementById('sample-player'); // <audio>
                var playContainer = document.getElementById('sample-container'); // <div>
                var isPlaying = (!player.paused);
                if (isPlaying)

                player.style = 'background:crimson; border-radius:27px';
                ;


                function sample_pause()

                var player = document.getElementById('sample-player'); // <audio>
                var playContainer = document.getElementById('sample-container'); // <div>
                var isPlaying = (!player.paused);
                if (!isPlaying)

                player.style = 'background:none; border-radius:27px';


                </script>


                thx for help, i need somebody, help, not just anybody, lol, beatles.
                this is the main loop (django/python) that populates items on page, it is in another file:



                 % for obj in object_list %
                <div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
                <div class="col my-auto ">
                % include 'products/snippets/card.html' with instance=obj %
                </div>
                </div>
                % endfor %


                what now?






                share|improve this answer













                this update works, but not correct. i might be missing a function loop, or something, code only works on first element on page.



                 <div id="sample-container"
                class="col-auto my-auto">
                <!-- sample player -->
                <!-- style="border-color:crimson" -->
                <!-- play="player_border();" -->
                <!-- style="background:crimson; border-radius:27px;" -->
                <audio id="sample-player"
                controls
                loop
                onplay="sample_play();"
                onpause="sample_pause()"
                class="btn btn-sm my-auto">
                <source src=" instance.audio.url "
                type="audio/mpeg">
                </audio>
                </div>
                <div class="col-auto my-auto">
                <span class="lead ml-1 my-auto text-warning"><b> instance.title </b></span>
                </div>
                </div>
                <!-- song description -->
                <div class="row my-auto pb-2 text-justify">
                <span class="text my-auto"> instance.description </span>
                </div>
                <!-- scripts -->
                <script type="text/javascript">
                function sample_play()

                var player = document.getElementById('sample-player'); // <audio>
                var playContainer = document.getElementById('sample-container'); // <div>
                var isPlaying = (!player.paused);
                if (isPlaying)

                player.style = 'background:crimson; border-radius:27px';
                ;


                function sample_pause()

                var player = document.getElementById('sample-player'); // <audio>
                var playContainer = document.getElementById('sample-container'); // <div>
                var isPlaying = (!player.paused);
                if (!isPlaying)

                player.style = 'background:none; border-radius:27px';


                </script>


                thx for help, i need somebody, help, not just anybody, lol, beatles.
                this is the main loop (django/python) that populates items on page, it is in another file:



                 % for obj in object_list %
                <div class="row mx-auto my-auto bg-transparent border-bottom border-primary">
                <div class="col my-auto ">
                % include 'products/snippets/card.html' with instance=obj %
                </div>
                </div>
                % endfor %


                what now?







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 23 at 3:48









                chistabochistabo

                34




                34





















                    0














                    making slow progress:
                    audio tag has two events, same function call:



                     onplay="sample_play()"
                    onpause="sample_play()"


                    function sample_play() has been simplified:



                     <script type="text/javascript">
                    function sample_play()

                    var player = document.getElementById('sample-player')
                    if (!player.paused)

                    player.style = 'background:crimson; border-radius:27px'

                    else

                    player.style = 'background:none; border-radius:27px'


                    </script>


                    but, still, it only works on first audio element on page. weird, i say.
                    thx for help.






                    share|improve this answer























                    • i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                      – chistabo
                      Mar 23 at 5:12















                    0














                    making slow progress:
                    audio tag has two events, same function call:



                     onplay="sample_play()"
                    onpause="sample_play()"


                    function sample_play() has been simplified:



                     <script type="text/javascript">
                    function sample_play()

                    var player = document.getElementById('sample-player')
                    if (!player.paused)

                    player.style = 'background:crimson; border-radius:27px'

                    else

                    player.style = 'background:none; border-radius:27px'


                    </script>


                    but, still, it only works on first audio element on page. weird, i say.
                    thx for help.






                    share|improve this answer























                    • i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                      – chistabo
                      Mar 23 at 5:12













                    0












                    0








                    0







                    making slow progress:
                    audio tag has two events, same function call:



                     onplay="sample_play()"
                    onpause="sample_play()"


                    function sample_play() has been simplified:



                     <script type="text/javascript">
                    function sample_play()

                    var player = document.getElementById('sample-player')
                    if (!player.paused)

                    player.style = 'background:crimson; border-radius:27px'

                    else

                    player.style = 'background:none; border-radius:27px'


                    </script>


                    but, still, it only works on first audio element on page. weird, i say.
                    thx for help.






                    share|improve this answer













                    making slow progress:
                    audio tag has two events, same function call:



                     onplay="sample_play()"
                    onpause="sample_play()"


                    function sample_play() has been simplified:



                     <script type="text/javascript">
                    function sample_play()

                    var player = document.getElementById('sample-player')
                    if (!player.paused)

                    player.style = 'background:crimson; border-radius:27px'

                    else

                    player.style = 'background:none; border-radius:27px'


                    </script>


                    but, still, it only works on first audio element on page. weird, i say.
                    thx for help.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 23 at 4:24









                    chistabochistabo

                    34




                    34












                    • i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                      – chistabo
                      Mar 23 at 5:12

















                    • i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                      – chistabo
                      Mar 23 at 5:12
















                    i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                    – chistabo
                    Mar 23 at 5:12





                    i tried moving sample_play() into main .js file, but it broke everything. revert? yes. lol

                    – chistabo
                    Mar 23 at 5:12

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55310157%2fhtml5-audio-set-border-color-with-javascript-when-playing%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해