# MultiType-FilePicker **Repository Path**: hihopeorg/MultiType-FilePicker ## Basic Information - **Project Name**: MultiType-FilePicker - **Description**: 文件选择器库,支持选择图片、视频、音频,拍照、录像、录音,播放视频、播放音频功能 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-08-06 - **Last Updated**: 2024-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MultiType-FilePicker **本项目是基于开源项目MultiType-FilePicker进行ohos化的移植和开发的,可以通过项目标签以及github地址(https://github.com/fishwjy/MultiType-FilePicker )追踪到原项目版本** ### 项目介绍 - 项目名称:文件选择器库 - 所属系列:ohos的第三方组件适配移植 - 功能:支持选择图片、视频、音频,拍照、录像、录音,播放视频、播放音频功能 - 项目移植状态:完成 - 调用差异:无 - 项目作者和维护人:hihope - 联系方式:hihope@hoperun.com - 原项目Doc地址:https://github.com/fishwjy/MultiType-FilePicker - 原项目基线版本:v1.0.8 , sha1:fbbcdbde53c0c8795c754e90c6c5f6c620976e43 - 编程语言:Java - 外部库依赖:无 ### 效果展示 ### 安装教程 方法1. 1. 编译har包MultiType-FilePicker.har。 2. 启动 DevEco Studio,将编译的har包,导入工程目录“entry->libs”下。 3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。 ``` dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) …… } ``` 4. 在导入的har包上点击右键,选择“Add as Library”对包进行引用,选择需要引用的模块,并点击“OK”即引用成功。 方法2. 1. 在工程的build.gradle的allprojects中,添加HAR所在的Maven仓地址 ``` repositories { maven { url 'http://106.15.92.248:8081/repository/Releases/' } } ``` 2. 在应用模块的build.gradle的dependencies闭包中,添加如下代码: ``` dependencies { implementation 'com.vincent.ohos:filepicker:1.0.0' } ``` ### 使用说明 #### 1.Start Ability For Result ``` case ResourceTable.Id_btn_pick_image: Intent intent1 = new Intent(); Operation operation = new Intent.OperationBuilder() .withDeviceId("") .withBundleName(getBundleName()) .withAbilityName(ImagePickAbility.class.getName()) .build(); intent1.setOperation(operation); intent1.setParam(IS_NEED_CAMERA, true); intent1.setParam(Constant.MAX_NUMBER, 9); intent1.setParam(IS_NEED_FOLDER_LIST, true); startAbilityForResult(intent1, Constant.REQUEST_CODE_PICK_IMAGE); break; case ResourceTable.Id_btn_pick_video: Intent intent2 = new Intent(); Operation operation2 = new Intent.OperationBuilder() .withDeviceId("") .withBundleName(getBundleName()) .withAbilityName(VideoPickAbility.class.getName()) .build(); intent2.setOperation(operation2); intent2.setParam(IS_NEED_CAMERA, true); intent2.setParam(Constant.MAX_NUMBER, 9); intent2.setParam(IS_NEED_FOLDER_LIST, true); startAbilityForResult(intent2, Constant.REQUEST_CODE_PICK_VIDEO); break; case ResourceTable.Id_btn_pick_audio: Intent intent3 = new Intent(); Operation operation3 = new Intent.OperationBuilder() .withDeviceId("") .withBundleName(getBundleName()) .withAbilityName(AudioPickAbility.class.getName()) .build(); intent3.setOperation(operation3); intent3.setParam(IS_NEED_RECORDER, true); intent3.setParam(Constant.MAX_NUMBER, 9); intent3.setParam(IS_NEED_FOLDER_LIST, true); startAbilityForResult(intent3, Constant.REQUEST_CODE_PICK_AUDIO); break; case ResourceTable.Id_btn_pick_file: Intent intent4 = new Intent(); Operation operation4 = new Intent.OperationBuilder() .withDeviceId("") .withBundleName(getBundleName()) .withAbilityName(NormalFilePickAbility.class.getName()) .build(); intent4.setOperation(operation4); intent4.setParam(Constant.MAX_NUMBER, 9); intent4.setParam(IS_NEED_FOLDER_LIST, true); intent4.setParam(NormalFilePickAbility.SUFFIX, new String[]{"xlsx", "xls", "doc", "dOcX", "ppt", ".pptx", "pdf"}); startAbilityForResult(intent4, Constant.REQUEST_CODE_PICK_FILE); break; ``` #### 2.Receive the Result from Ability ``` case Constant.REQUEST_CODE_PICK_IMAGE: if (resultCode == RESULT_OK) { ArrayList list = data.getSequenceableArrayListParam(Constant.RESULT_PICK_IMAGE); StringBuilder builder = new StringBuilder(); for (ImageFile file : list) { String path = file.getPath(); builder.append(path + "\n"); } mTvResult.setText(builder.toString()); } break; case Constant.REQUEST_CODE_PICK_VIDEO: if (resultCode == RESULT_OK) { ArrayList list = data.getSequenceableArrayListParam(Constant.RESULT_PICK_VIDEO); StringBuilder builder = new StringBuilder(); for (VideoFile file : list) { String path = file.getPath(); builder.append(path + "\n"); } mTvResult.setText(builder.toString()); } break; case Constant.REQUEST_CODE_PICK_AUDIO: if (resultCode == RESULT_OK) { ArrayList list = data.getSequenceableArrayListParam(Constant.RESULT_PICK_AUDIO); StringBuilder builder = new StringBuilder(); for (AudioFile file : list) { String path = file.getPath(); builder.append(path + "\n"); } mTvResult.setText(builder.toString()); } break; case Constant.REQUEST_CODE_PICK_FILE: if (resultCode == RESULT_OK) { ArrayList list = data.getSequenceableArrayListParam(Constant.RESULT_PICK_FILE); StringBuilder builder = new StringBuilder(); for (NormalFile file : list) { String path = file.getPath(); builder.append(path + "\n"); } mTvResult.setText(builder.toString()); } break; ``` ### 版本迭代 - v1.0.0 - 已实现功能 1. CHOOSE IMAGE 2. CHOOSE VIDEO 3. CHOOSE AUDIO 4. CHOOSE FILE ### 版权和许可信息 ``` Copyright 2016 Vincent Woo Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```