当前位置: 首页 > 软件库 > 手机/移动开发 > >

nativescript-volume

授权协议 MIT License
开发语言 JavaScript TypeScript
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 鱼恩
操作系统 iOS
开源组织
适用人群 未知
 软件概览

NativeScript-Volume

This plugin allows you to programmatically control the volume in a NativeScript application. This is compatible with both iOS and Android.

Installation

Run the following command from the root of your project:

tns plugin add nativescript-volume

This command automatically installs the necessary files, as well as stores nativescript-volume as a dependency in your project's package.json file.

Usage

This plugin can be used with any flavor of NativeScript (Core, Angular, Vue, TypeScript, and/or JavaScript).

TypeScript

import { Volume } from 'nativescript-volume';

export SomeClass {
  private volume: Volume;

  constructor() {
    this.volume = new Volume();
  }

  mute() {
    this.volume.mute();
  }

  unmute() {
    this.volume.unmute();
  }

  volumeUp() {
    this.volume.volumeUp();
  }

  volumeHalf() {
    if (app.ios) {
      // iOS Volume goes from 0 to 1. With its increments being 1/16.
      this.volume.setVolume(0.5);
    } else if (app.android) {
      // Android Volume I'm unsure of the range, but believe it to be 0 to 15 at least for the music stream.
      this.volume.setVolume(7);
    }
  }

  volumeDown() {
    this.volume.volumeDown();
  }

  getVolume() {
    // Please see Android TODO in the Api Section
    alert('Volume is' + this.volume.getVolume());
  }
}

API

Method: ReturnType Description Notes
mute(): void Mutes the volume of the Device
unmute(): void Unmutes the volume of the Device
volumeDown(): void Decreases the volume of the Device. Android The device picks the active sound stream.
volumeUp(): void Increases the volume of the Device. Android The device picks the active sound stream.
getVolume(): number Gets the current volume of the Device. Android This currently only gets the music stream's volume.
setVolume(value: number): void Sets the current volume of the Device. Android This currently only sets the music stream's volume.

License

The MIT License

  • 1. 前言 Android提供了很多的多媒体接口,通常在java层,我们常用的就是AudioTrack和MediaPlayer进行音频播放。MediaPlayer不光可以播放音频,也可以播放视频,并支持少部分的解码。 而由于音视频通常计算量都很大,所以很多音视频方面的工作都会放在native层进行。Android在native层同样提供了一些组件来进行音频的播放和录制: OpenSL ES:这是A

 相关资料
  • NativeScript 可以使用 Javascript,CSS, XML 创建真正的 Native 跨平台应用,支持 iOS Android,NativeScript 将您的跨平台代码翻译成目标平台的代码。 UI 使用 XML 描述,CSS 样式,在编译时将 UI 转化成本地原生代码,最终得到正在的 Native 原生应用。 Telerik 公开了用于创建安卓、iOS和Windows Unive

  • NativeScript Command-Line Interface The NativeScript CLI lets you create, build, and deploy NativeScript-based apps on iOS and Android devices. Get it using: npm install -g nativescript What is Native

  • NativeScript-Snackbar �� �� �� NativeScript plugin for Material Design SnackBar component. Installation: NativeScript 7+:tns plugin add @nstudio/nativescript-snackbar NativeScript version prior to 7:t

  • Nativescript-Ripple This plugin aims to bring a native (or close to native) ripple implementation on Android and iOS. The android version uses a RippleDrawable and conserves the previous background, a

  • NativeScript-FloatingActionButton NativeScript plugin for Material Design Floating Action Button UI component. Installation Nativescript 7+: ns plugin add @nstudio/nativescript-floatingactionbutton Na

  • NativeScript CardView A NativeScript plugin to provide an XML widget to implement the Material Design CardView component. Installation NativeScript 7+: ns plugin add @nstudio/nativescript-cardview Nat