简体   繁体   English

使用 flutter 在 iOS 设备中播放 base64 音频文件

[英]Play base64 audio file in iOS devices using flutter

I'm trying to play audio files in a flutter app.我正在尝试在 flutter 应用程序中播放音频文件。 I do have base64 audio files which AudioPlayers package can handle in android but is not working in iOS devices.我确实有 base64 个音频文件,音频播放器package可以在 android 中处理,但在 iOS 设备中不起作用。 Is there any means i can play base64 audio files in iOS devices using flutter?有什么办法可以使用 flutter 在 iOS 设备中播放 base64 音频文件吗? I have spent hours trying to figure it out but to no avail.我花了几个小时试图弄清楚但无济于事。

There is already a answer for this question in Stackoverflow Stackoverflow 中已经有这个问题的答案

List<int> fileBytes = await file.readAsBytes();
String base64String = base64Encode(fileBytes);

Kindly refer this link for full info请参考此链接以获取完整信息

or you can use this或者你可以用这个

import 'dart:convert';
import 'dart:io';

class FileConverter {
  static String getBase64FormateFile(String path) {
    File file = File(path);
    print('File is = ' + file.toString());
    List<int> fileInByte = file.readAsBytesSync();
    String fileInBase64 = base64Encode(fileInByte);
    return fileInBase64;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM