copyright-free-songs
A Dart package that provides utilities for accessing and managing data related to copyright-free songs. This package simplifies the integration of royalty-free music information into your Dart applications.
Installation
To use this package, add copyright-free-songs as a dependency in your pubspec.yaml file:
yaml
dependencies:
copyright_free_songs: ^1.0.0 # Replace with the latest version
Then, run dart pub get to install the package.
Usage
Here are a few examples demonstrating how to use the copyright-free-songs package:
1. Retrieving a List of Song Titles: dart import 'package:copyright_free_songs/copyright_free_songs.dart';
void main() async { final songManager = SongManager(); final songTitles = await songManager.getSongTitles();
if (songTitles.isNotEmpty) { print('Available Song Titles:'); for (var title in songTitles) { print('- $title'); } } else { print('No song titles found.'); } }
2. Fetching Song Details by ID: dart import 'package:copyright_free_songs/copyright_free_songs.dart';
void main() async { final songManager = SongManager(); final songDetails = await songManager.getSongDetails(songId: 'song_001'); // Replace with a valid song ID
if (songDetails != null) { print('Song Details:'); print(' Title: ${songDetails.title}'); print(' Artist: ${songDetails.artist}'); print(' Genre: ${songDetails.genre}'); print(' License: ${songDetails.license}'); } else { print('Song not found.'); } }
3. Searching for Songs by Genre: dart import 'package:copyright_free_songs/copyright_free_songs.dart';
void main() async { final songManager = SongManager(); final songs = await songManager.searchSongsByGenre(genre: 'Electronic');
if (songs.isNotEmpty) { print('Electronic Songs:'); for (var song in songs) { print('- ${song.title} by ${song.artist}'); } } else { print('No electronic songs found.'); } }
4. Checking if a Song is Available: dart import 'package:copyright_free_songs/copyright_free_songs.dart';
void main() async { final songManager = SongManager(); final isAvailable = await songManager.isSongAvailable(songId: 'song_002'); // Replace with a valid song ID
if (isAvailable) { print('Song is available.'); } else { print('Song is not available.'); } }
5. Retrieving a Random Song: dart import 'package:copyright_free_songs/copyright_free_songs.dart';
void main() async { final songManager = SongManager(); final randomSong = await songManager.getRandomSong();
if (randomSong != null) { print('Random Song:'); print(' Title: ${randomSong.title}'); print(' Artist: ${randomSong.artist}'); } else { print('Could not retrieve a random song.'); } }
Features
- Easy Integration: Simplifies the process of incorporating copyright-free song data into your Dart projects.
- Song Retrieval: Provides methods for retrieving song details by ID, genre, or randomly.
- Song Availability: Allows you to check if a particular song is currently available.
- Data Abstraction: Offers a clean and consistent API for accessing song information.
- Asynchronous Operations: Leverages
async/awaitfor non-blocking data retrieval.
License
MIT
This package is part of the copyright-free-songs ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/music/copyright-free-songs/