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

패키지 상세v4.0.0+4

flutter_ringtone_player

시스템 기본 알림음, 알람 및 알림을 위한 간단한 플레이어

AndroidiOS
30일 다운로드
2.6천
좋아요
287
Pub 점수
150

패키지 설치

flutter pub add flutter_ringtone_player

패키지 개요

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

Android 및 iOS 장치에서 시스템 기본 알림음, 알람 및 알림을 재생할 수 있는 가벼운 Flutter 패키지입니다. 외부 파일 처리 없이 내장된 사운드 자산에 액세스하고 재생하기 위한 간단한 API를 제공합니다. 리마인더, 경고 또는 알림 소리와 같은 기기별 오디오 신호를 트리거해야 하는 앱에 적합합니다. 이 패키지는 네이티브 플랫폼 오디오 시스템과 원활하게 통합되며 최소한의 구성으로 두 플랫폼 모두를 지원합니다.

사용 사례

  • 알림 앱에서 시스템 알림음 재생하기
  • 작업 관리 도구에서 알람 사운드 트리거
  • 메시징 앱에서 알림 음성 재생하기
  • 유틸리티 앱에서 장치 경보 사운드 시뮬레이션
  • 사운드 모드 백업을 벨톤 재생과 함께 활성화

주요 기능

  • 시스템 기본 알림음에 대한 액세스
  • Android 및 iOS 지원
  • 최소한의 설정 및 통합
  • 크로스 플랫폼 호환성
  • 간단한 재생 제어 API

적합한 대상

  • 알림 또는 경고 앱을 개발하는 개발자
  • 네이티브 알림 사운드가 필요한 앱
  • 기기의 오디오 피드백이 필요한 유틸리티 도구
  • Android 및 iOS를 대상으로 하는 모바일 앱

고려 사항

  • 적절한 플랫폼 권한이 필요합니다
  • 시스템에서 제공하는 오디오 리소스에 한정
  • 사용자 지정 반향 파일 지원 없음
  • Android와 iOS 간에 동작이 약간 다를 수 있습니다
  • 네이티브 시스템 오디오 사용 가능 여부에 의존

원본 README

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

flutter_ringtone_player

A simple ringtone, alarm & notification player plugin.

pub package flutter

Usage

Add following import to your code:

import 'package:flutter_ringtone_player/flutter_ringtone_player.dart';

Then simply call this to play system default notification sound:

FlutterRingtonePlayer().playNotification();

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

FlutterRingtonePlayer().play(
  android: AndroidSounds.notification,
  ios: IosSounds.glass,
  looping: true, // Android only - API >= 28
  volume: 0.1, // Android only - API >= 28
  asAlarm: false, // Android only - all APIs
);

Also you can specify a custom ringtone from assets, or provide direct path to file that works for both Android and iOS:

FlutterRingtonePlayer().play(fromAsset: "assets/ringtone.wav");  
FlutterRingtonePlayer().play(fromFile: "assets/ringtone.wav");  

You can specify a platform specific ringtone and it will override the one from assets:

FlutterRingtonePlayer().play(  
 fromAsset: "assets/ringtone.wav", // will be the sound on Android
 ios: IosSounds.glass 			   // will be the sound on iOS
 );  
.play() optional attributes
Attribute Description
bool looping Enables looping of ringtone. Requires FlutterRingtonePlayer().stop(); to stop ringing.
double volume Sets ringtone volume in range 0 to 1.0.
bool asAlarm Allows to ignore device's silent/vibration mode and play given sound anyway.

To stop looped ringtone please use:

FlutterRingtonePlayer().stop();

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

Default sounds

Method Android iOS
playAlarm RingtoneManager.TYPE_ALARM IosSounds.alarm
playNotification RingtoneManager.TYPE_NOTIFICATION IosSounds.triTone
playRingtone RingtoneManager.TYPE_RINGTONE IosSounds.electronic
Note on iOS sounds

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

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

카테고리

의존성

의존성 목록 2 개

소스 저장소

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