• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3734

entry/12-May-2024-1,8811,618

screenshots/device/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-20241.5 KiB3216

README_zh.mdD12-May-20241.7 KiB3517

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024168 21

package.jsonD12-May-2024409 1919

README.md

1# Distributed Music Player
2
3### Introduction
4
5In this sample, **fileIo** is used to obtain an audio file; **AudioPlayer** is used to play music, pause the playback, and play the next or previous song; **DeviceManager** is used to display the distributed device list and hop music playback across devices. The display effect is as follows:
6
7![](./screenshots/device/distributedMusicPlayer_en.png)
8
9### Concepts
10
11Audio playback: The media subsystem provides audio and video services and implements audio playback by using **AudioPlayer**.
12
13Data hop: The distributed data management module implements collaboration between databases of different devices for applications. The APIs provided by distributed data management can be used to save data to the distributed database and perform operations such as adding, deleting, modifying, and querying data in the distributed database.
14
15### Required Permissions
16
17ohos.permission.DISTRIBUTED_DATASYNC
18
19### Usage
20
211. Play music. Touch the buttons on the music player to play music, pause the playback, and play the next or previous music clip.
22
232. Play music across devices. On the Super Device formed by multiple networked devices, touch the **Hop** button and select a device to play the music on the peer device.
24
25### Constraints
26
27- This sample can only be run on standard-system devices.
28
29- This sample is based on the stage model, which is supported from API version 9.
30
31- This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
32

README_zh.md

1# 分布式音乐播放
2
3### 简介
4
5本示例使用fileIo获取指定音频文件,并通过AudioPlayer完成了音乐的播放完成了基本的音乐播放、暂停、上一曲、下一曲功能;并使用DeviceManager完成了分布式设备列表的显示和分布式能力完成了音乐播放状态的跨设备迁移。实现效果如下:
6
7![](./screenshots/device/distributedMusicPlayer.png)
8
9### 相关概念
10
11音频播放:媒体子系统包含了音视频相关媒体业务,通过AudioPlayer实现音频播放的能力。
12
13数据流转:分布式数据管理为应用程序提供不同设备间数据库的分布式协同能力。通过调用分布式数据各个接口,应用程序可将数据保存到分布式数据库中,并可对分布式数据库中的数据进行增/删/改/查等各项操作。
14
15### 相关权限
16
17允许不同设备间的数据交换:ohos.permission.DISTRIBUTED_DATASYNC
18
19### 使用说明
20
211.**音乐播放**,点击**播放**、**暂停**、上**一曲**、下**一曲**按钮可以对音乐进行操作。
22
232.**跨设备迁移播放**,组网条件下,点击**流转**按钮,选择设备,拉起对端设备上的音乐,本端退出。
24
25### 约束与限制
26
271.本示例仅支持标准系统上运行。
28
292.本示例为stage模型,从API version 9开始支持。
30
313.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
32
334.本示例需要使用@ohos.distributedHardware.deviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md)34
35