sound/src/main/java/org/apidesign/html/sound/impl/BrowserAudioEnv.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 07 Aug 2013 15:29:42 +0200
branchsound
changeset 223 ef2399c0fb9e
child 249 18430f810b7e
permissions -rw-r--r--
Implementation of the AudioClip that uses HTML5 Audio tag
jaroslav@223
     1
/**
jaroslav@223
     2
 * HTML via Java(tm) Language Bindings
jaroslav@223
     3
 * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@223
     4
 *
jaroslav@223
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@223
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@223
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@223
     8
 *
jaroslav@223
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@223
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@223
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@223
    12
 * GNU General Public License for more details. apidesign.org
jaroslav@223
    13
 * designates this particular file as subject to the
jaroslav@223
    14
 * "Classpath" exception as provided by apidesign.org
jaroslav@223
    15
 * in the License file that accompanied this code.
jaroslav@223
    16
 *
jaroslav@223
    17
 * You should have received a copy of the GNU General Public License
jaroslav@223
    18
 * along with this program. Look for COPYING file in the top folder.
jaroslav@223
    19
 * If not, see http://wiki.apidesign.org/wiki/GPLwithClassPathException
jaroslav@223
    20
 */
jaroslav@223
    21
package org.apidesign.html.sound.impl;
jaroslav@223
    22
jaroslav@223
    23
import net.java.html.js.JavaScriptBody;
jaroslav@223
    24
import org.apidesign.html.sound.spi.AudioEnvironment;
jaroslav@223
    25
import org.openide.util.lookup.ServiceProvider;
jaroslav@223
    26
jaroslav@223
    27
/** Registers an audio provider that delegates to HTML5 Audio tag.
jaroslav@223
    28
 *
jaroslav@223
    29
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@223
    30
 */
jaroslav@223
    31
@ServiceProvider(service = AudioEnvironment.class, position = 100)
jaroslav@223
    32
public final class BrowserAudioEnv implements AudioEnvironment<Object> {
jaroslav@223
    33
    @Override
jaroslav@223
    34
    @JavaScriptBody(args = { "src" }, body = ""
jaroslav@223
    35
        + "if (!Audio) return null;"
jaroslav@223
    36
        + "return new Audio(src);")
jaroslav@223
    37
    public Object create(String src) {
jaroslav@223
    38
        // null if not running in browser
jaroslav@223
    39
        return null;
jaroslav@223
    40
    }
jaroslav@223
    41
jaroslav@223
    42
    @Override @JavaScriptBody(args = { "a" }, body = "a.play();")
jaroslav@223
    43
    public void play(Object a) {
jaroslav@223
    44
    }
jaroslav@223
    45
jaroslav@223
    46
    @Override @JavaScriptBody(args = { "a" }, body = "a.pause();")
jaroslav@223
    47
    public void pause(Object a) {
jaroslav@223
    48
    }
jaroslav@223
    49
jaroslav@223
    50
    @Override @JavaScriptBody(args = { "a", "volume" }, body = "a.setVolume(volume);")
jaroslav@223
    51
    public void setVolume(Object a, double volume) {
jaroslav@223
    52
    }
jaroslav@223
    53
}