• Home
Name Date Size #Lines LOC

..--

entry/12-May-2024-1,4551,256

screenshots/device/12-May-2024-

.gitignoreD12-May-2024121 88

README.mdD12-May-20241.9 KiB4120

README_zh.mdD12-May-20242.1 KiB4321

build-profile.json5D12-May-20241 KiB4241

hvigorfile.jsD12-May-2024174 21

package.jsonD12-May-2024388 1918

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<img src="screenshots/device/music2_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
30- This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
31
32- If the app is set as a preset app, "error: install sign info inconsistent" will be displayed during the app installation. If this occurs, run the following commands to install the app and restart the device after the installation:
33
34  **hdc shell mount -o rw,remount /**
35
36  **hdc file send ./entry-default-signed.hap /system/app/com.ohos.distributedmusicplayer/Music_Demo.hap**
37
38  **hdc shell  reboot**
39
40After the device is restarted, the app is installed. No other operation is required.
41

README_zh.md

1# 分布式音乐播放
2
3### 简介
4
5本示例使用fileIo获取指定音频文件,并通过AudioPlayer完成了音乐的播放完成了基本的音乐播放、暂停、上一曲、下一曲功能;并使用DeviceManager完成了分布式设备列表的显示和分布式能力完成了音乐播放状态的跨设备迁移。实现效果如下:
6
7<img src="screenshots/device/music2.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.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
30
313.如果安装本示例报错为error:install sign info inconsistent,则有可能本应用被设置为系统预置应用,已安装在系统中,此时需使用命令进行替换安装,并在替换安装后对设备进行重启操作,具体命令如下:
32
33hdc shell mount -o rw,remount /
34
35hdc file send ./entry-default-signed.hap /system/app/com.ohos.distributedmusicplayer/Music_Demo.hap
36
37hdc shell  reboot
38
39等设备重启后即可完成应用的替换安装,无需其他操作。
40
414.本示例需要使用@ohos.distributedHardware.deviceManager系统权限的系统接口。使用Full SDK时需要手动从镜像站点获取,并在DevEco Studio中替换,具体操作可参考[替换指南](https://docs.openharmony.cn/pages/v3.2/zh-cn/application-dev/quick-start/full-sdk-switch-guide.md/)42
43