패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.1.1

ringtone_player

시스템 기본 알림음, 알람 및 알림을 위한 플레이어입니다.

AndroidiOS
30일 다운로드
82
좋아요
22
Pub 점수
130

패키지 설치

flutter pub add ringtone_player

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

ringtone_player 패키지는 Flutter 애플리케이션에서 안드로이드 및 iOS 기기에서 시스템 기본 알림음, 알람 및 알림을 재생할 수 있도록 합니다. 외부 파일 없이 시스템 오디오 리소스에 접근하고 재생할 수 있는 간단한 인터페이스를 제공합니다. 리마인더나 경고와 같은 디바이스 레벨 사운드를 트리거해야 하는 앱용으로 설계되었으며, 네이티브 오디오 시스템과 원활하게 통합됩니다. 플랫폼별 동작을 지원하며 가볍기 때문에 모바일 앱 내 기본 오디오 재생 요구사항에 이상적입니다.

사용 사례

  • 알림 앱에서 시스템 알림음 재생하기
  • 작업 관리 도구에서 알람 사운드 트리거
  • 메시징 앱에서 알림 음성 재생
  • 테스트 환경에서 장치 경고 시뮬레이션
  • 청각적 신호를 통해 접근성 기능 향상

주요 기능

  • 시스템 기본 알림음에 대한 액세스
  • Android 및 iOS 플랫폼을 지원합니다
  • 시스템 사운드 재생을 위한 간단한 API
  • 최소 종속성 오버헤드
  • 플랫폼 인식 오디오 처리

적합한 대상

  • 시스템 사운드 통합이 필요한 모바일 앱
  • 알림 또는 경고 시스템을 구축하는 개발자
  • 접근성 또는 사용자 피드백에 중점을 둔 앱
  • 경량 오디오 재생 요구 사항
  • 크로스 플랫폼 오디오 기능

고려 사항

  • 시스템에서 제공하는 오디오 리소스에 제한됨
  • 사용자 정의 오디오 파일 지원 없음
  • 적절한 플랫폼 권한이 필요합니다
  • 기기 제조업체에 따라 동작이 다를 수 있습니다
  • 네이티브 시스템 톤 사용 가능 여부에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

ringtone_player

A player for system default ringtone, alarm and notification.

Pub Version

Installation

Add following dependencies to your pubspec.yaml:

dependencies:
  ringtone_player: ^0.1.1 #latest version

Usage

Add following import to your code:

import 'package:ringtone_player/ringtone_player.dart';

Then simply call this to play system default notification sound:

RingtonePlayer.ringtone();

There's also this generic method allowing you to specify in detail what kind of ringtone should be played:

RingtonePlayer.play(
  alarmMeta: AlarmMeta(
    'dev.cruv.ringtone_player_example.MainActivity',
    'ic_alarm_notification',
    contentTitle: 'Alarm',
    contentText: 'Alarm is active',
    subText: 'Subtext',
  ),
  android: Android.ringtone,
  ios: Ios.electronic,
  loop: true, // Android only - API >= 28
  volume: 1.0, // Android only - API >= 28
  alarm: true, // Android only - all APIs
);

.play() optional attributes
Attribute Description
bool loop Enables loop of ringtone. If Requires
double volume Sets ringtone volume in range 0 to 1.0.
bool alarm Allows to ignore device's silent/vibration mode and play given sound anyway.

To stop looped ringtone please use:

RingtonePlayer.stop();

Above works only on Android, and please note that by default Alarm & Ringtone sounds are looped.

Default sounds

Method Android iOS
alarm System#DEFAULT_ALARM_ALERT_URI Ios.alarm
notification System#DEFAULT_NOTIFICATION_URI Ios.triTone
ringtone System#DEFAULT_RINGTONE_URI Ios.electronic

Note for AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="dev.cruv.ringtone_player_example">

    <!-- Must add this line -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <!-- -->

    <application
        android:icon="@mipmap/ic_launcher"
        android:label="Ringtone_player_example"
        tools:ignore="AllowBackup">

        <!-- Must add this line -->
        <service android:name="dev.cruv.ringtone_player.PlayerService" />
        <!-- -->

        <activity>...</activity>
        ...
    </application>
</manifest>

Note on iOS sound

If you want to use any other sound on iOS you can always specify a valid Sound ID and manually construct [IosSound]:

RingtonePlayer.play(
  android: Android.notification,
  ios: const IosSound(1023),
  looping: true,
  volume: 0.1,
);

License

MIT License

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.