Skip to content

Legacy API: AudioControl

Hyojin Kim edited this page Mar 21, 2017 · 2 revisions

For converting TVAudioControl API of Legacy to TOAST API, please refer to the followings.

If you want more information, please refer to toast.tvaudiocontrol

setMute

  • Before

    /* plugin */
    var PLR_TRUE = 1;
    var PLR_FALSE = 0;
    
    var audioPlugin = document.getElementById('audioPlugin');
    audioPlugin.SetMute(PLR_TRUE);
    /* SEF */
    var PLR_TRUE = 1;
    var PLR_FALSE = 0;
    
    var sef = document.getElementById('sef');
    sef.Open('Audio', '1.0', 'Audio');
    sef.Execute('SetUserMute', PLR_TRUE);
    /* webapis */
    var userMute = true;
    webapis.audiocontrol.setMute(userMute);
  • After

    // true : turn on the silent mode
    // false : trun off the silent mode
    var mute = true;
    toast.tvaudiocontrol.setMute(mute, function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });

isMute

  • Before

    /* plugin */
    audioPlugin.GetMute();
    /* SEF */
    sef.Execute('GetUserMute');
    /* webapis */
    webapis.audiocontrol.getMute();
  • After

    toast.tvaudiocontrol.isMute(function(value) {
        // value : state of mute
        console.log('Success: ' + value);
    }, function(err) {
        console.log('Error: ' + err.message);
    });

setVolume

  • Before

    /* plugin */
    var volume = 5;
    audioPlugin.SetVolume(volume);
    /* SEF */
    var volume = 5;
    sef.Execute('SetVolume', volume);
    /* webapis */
    var volume = 5;
    webapis.audiocontrol.setVolume(volume);
  • After

    var volume = 5;
    toast.tvaudiocontrol.setVolume(volume, function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });

setVolumeUp

  • Before

    var PL_AUDIO_VOLUME_KEY_UP = 0;
    var PL_AUDIO_VOLUME_KEY_DOWN = 1;
    /* plugin */
    audioPlugin.SetVolumeWithKey(PL_AUDIO_VOLUME_KEY_UP); 
    // PL_AUDIO_VOLUME_KEY_UP : increment volume level
    /* SEF */
    sef.Execute('SetVolumeWithKey', PL_AUDIO_VOLUME_KEY_UP); 
    // PL_AUDIO_VOLUME_KEY_UP : increment volume level
    /* webapis */
    webapis.audiocontrol.setVolumeUp();
  • After

    toast.tvaudiocontrol.setVolumeUp(function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });

setVolumeDown

  • Before

    var PL_AUDIO_VOLUME_KEY_UP = 0;
    var PL_AUDIO_VOLUME_KEY_DOWN = 1;
    /* plugin */
    audioPlugin.SetVolumeWithKey(PL_AUDIO_VOLUME_KEY_DOWN); 
    // PL_AUDIO_VOLUME_KEY_DOWN : decrement volume level
    /* SEF */
    sef.Execute('SetVolumeWithKey', PL_AUDIO_VOLUME_KEY_DOWN); 
    // PL_AUDIO_VOLUME_KEY_DOWN : decrement volume level
    /* webapis */
    webapis.audiocontrol.setVolumeDown();
  • After

    toast.tvaudiocontrol.setVolumeDown(function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });

getVolume

  • Before

    /* plugin */
    audioPlugin.GetVolume();
    /* SEF */
    sef.Execute('GetVolume');
    /* webapis */
    webapis.audiocontorl.getVolume();
  • After

    toast.tvaudiocontrol.getVolume(function(value) {
        // value : current volume
        console.log('Success: ' + value);
    }, function(err) {
        console.log('Error: ' + err.message);
    });

setVolumeChangeListener

  • Before

    /* Not supported */
  • After

    function onVolumeChanged(volume){
        console.log('volume changes to ' + value);
    }
    toast.tvaudiocontrol.setVolumeChangeListener(onVolumeChanged, function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });

unsetVolumeChangeListener

  • Before

    /* Not supported */
  • After

    toast.tvaudiocontrol.unsetVolumeChangeListener(function() {
        console.log('Success');
    }, function(err) {
        console.log('Error: ' + err.message);
    });
Clone this wiki locally