# Javascript Media Restrictions to be Aware Of

DevFeed: [Javascript Media Restrictions to be Aware Of](<https://devfeed.tech/articles/javascript-media-restrictions-to-be-aware-of-19344.md>)

Original publisher: [Read original article](<https://www.codenameone.com/blog/javascript-media-restrictions/>)

Author: Steve Hannah

Published: 2019-12-18T00:00:00Z

Content type: tutorial

Language: en

Sources: [CodeName One](<https://devfeed.tech/sources/codename-one.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Playback](<https://devfeed.tech/topics/playback.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [browser](<https://devfeed.tech/tags/browser.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [playback](<https://devfeed.tech/tags/playback.md>), [web](<https://devfeed.tech/tags/web.md>)

## AI overview

This tutorial explains how modern web browsers restrict audio playback in Codename One apps deployed through the Javascript port. Audio generally must be triggered by direct user interaction; the article describes the media API's fallback dialog and recommends reusing media elements and calling cleanup() when playing multiple clips.

## Source excerpt

Codename One provides play() and pause() methods as part of the Media interface, which you can use to start and stop media clips programmatically. If you are deploying your app to the browser using the Javascript port, then you should be aware of some restrictions imposed by modern web browsers on media playback, and how to work around them. Modern browsers will only allow audio playback that is triggered by direct user interaction. This basically means that the user needs to press a button to trigger audio playback.