Embedded Audio and Autoplay

Toejam08
Toejam08

I have been trying to figure out a way to turn off autoplay for an embedded audio file.

For context, I have uploaded the audio file to Obsidian Portal, where pictures are uploaded, and then used the "Link Image" button on the wiki page to link the audio file. The link then applies the classes .oembed and .cloundfront-audio to the code and, when the page loads, it seems javascript runs and replaces that div and link with an iframe tag and a video tag to host the audio file.

It's actually all great and works awesome on the page! The only thing is it autoplays the file on my desktop computer (my phone does not autoplay it). I want to have a different audio file autoplay on the same page eventually and have this one default to not autoplay.  I would also like to be able to autoplay an audio file on the phone but I don't know if that is possible. 

tldr: How do I control whether autoplay is on or off for embedded audio files?

Comments

  • Toejam08
    Toejam08
    Posts: 11 edited November 2017

    I found a way around it but if anyone has a suggestion as to just change the autoplay setting, please let me know. 

    Basically what I have currently done is changed the .cloudfront-audio class to .cloudfront-video

    The video class does not inject an autoplay attribute to the video tag it creates.

    This changes the way it looks though and I had to add a second class .music and custom css to squish the video player down to just show the controls instead of a blank screen.

    Basically this was the CSS that I used to shape the video player it creates:

     

    .oembed.cloudfront-video.music {

        margin: 30px auto;

        height: 38px;

        overflow: hidden;

    }

    .oembed.cloudfront-video.music video {

        margin-top: -210px;

    }

     

    You can see the results here: http://grandbeginning.obsidianportal.com/wikis/the-graveyard

    Post edited by Toejam08 on
  • Abersade
    Abersade
    Posts: 420

    Oddly enough I've been trying to do the exact opposite as you, I wanted an audio file to autoplay and wasn't having much luck getting it working. It never occurred to me to do as you did, now it's working the way I wanted it to. Thanks!

    GM of Rise of the Durnskald: Wrath of the Fallen Goddess - February 2016 CotM

    GM of Core: The Ashes of Alcarna - April 2020 CotM

    GM of Stream of Kairos

    Need CSS Help? It may be covered here: Abersade's CSS Hub

  • SkidAce
    SkidAce
    Posts: 830

    It still autoplayed for me at the link you provided.

  • Toejam08
    Toejam08
    Posts: 11

    SkidAce, I have added a second track that I intended to autoplay with the original down the page that does not autoplay.

    Abersade, I'm glad I could help you!

Sign In or Register to comment.

April 2024
Season of Strife

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Discussions