GithubHelp home page GithubHelp logo

crcdng / aframe-startplay-component Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 12.47 MB

Tries to autoplay an audio/video element and provides a button for user interaction as a fallback option

License: MIT License

HTML 30.16% JavaScript 69.84%

aframe-startplay-component's Introduction

aframe-startplay-component

Update: archiving this component

Version License

Many environments, especially mobile browsers, are blocking autoplay of audio or video and require an user interaction instead. Policies and rules that govern this behavior are constantly changing. Yet we would like to play background music or video textures in our VR scenes.

This component attempts to autoplay an audio/video element and provides a button for user interaction as a fallback option. You need a non-fuse cursor element / controller that can trigger a click event on the button. Make sure to set the position/rotation of the button relative to your start position.

Built to work with <a-sound>, <a-video>, <a-videosphere>, <a-entity src="#video_id">, <a-entity sound="src: #audio_id">.

** The development is in an early stage. You can help improving it by checking out the examples, experimenting with it and submitting bug reports / pull requests. ** When the component is somewhat stable and has been tested a bit, I will add it on npm.

Check out the examples.

To-do list:

  • Test a lot on different device / browser combinations and test with A-Frame 9.x
  • Check that media is loaded before autoplay attempt
  • Bundle the default font with webpack. Currently the Roboto font is loaded from a CDN (de-faulty behavior for the text component. This breaks the app in an Intranet scenario, where you would have a local server and no web access.)
  • Add font choices (font, size, color)
  • Add material choices for the Button
  • Maybe add a muted video autoplay option, where videos are played automatically and can be unmuted manually
  • Maybe add the option to enter VR mode with the action

For A-Frame.

API

Property Description Default Value
autohide Shall the Button go away after being clicked? true
autoplay Attempt to autoplay the element? yes
buttonId Id of the Button "startplaybtn"
buttonColor Color of the Button "black"
position Button position { x: 0, y: 0, z: 0 }
rotation Button rotation { x: 0, y: 0, z: 0 }
size Button size { x: 3, y: 1.5 }
text Button text "START"
textColor Color of the Text "white"

Installation

Browser

Install and use by directly including the browser files:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
  <script src="https://unpkg.com/aframe-startplay-component/dist/aframe-startplay-component.min.js"></script>
</head>

<body>
  <a-assets>
    <audio id="background" src="music.mp3"><audio>
  </a-assets>
  <a-scene>
    <a-sound src="#background" startplay></a-entity>
  </a-scene>
</body>

npm (NOT OPERATIONAL AT THE MOMENT)

Install via npm:

npm install aframe-startplay-component

Then require and use.

require('aframe');
require('aframe-startplay-component');

aframe-startplay-component's People

Stargazers

 avatar

Watchers

 avatar  avatar

aframe-startplay-component's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.