gpt4 book ai didi

android - Nativescript 中的 RAW 文件(音频)文件夹

转载 作者:行者123 更新时间:2023-11-29 18:36:01 24 4
gpt4 key购买 nike

NativeScript 在打包应用程序时是否自动考虑 raw 文件夹?

我找不到任何对此的引用。所以我要做的是在该文件夹中存储一个 .mp3 文件,然后将其用作自定义通知声音。

问题是:我怎样才能引用那个文件?我应该写什么作为路径?这是相关代码:

// how should my path be like here?
const sound = android.net.Uri.fromFile(new java.io.File('path????'));

const notification = notificationBuilder
.setSmallIcon(ad.resources.getDrawableId('icon'))
.setContentTitle('Some test notification')
.setContentText('Done with native builder')
.setPriority(2)
.setSound()
.setVibrate([0, 550, 200, 500])
.setLights(200, 500, 1000)
.build();

提前感谢任何愿意提供帮助的人❤️❤️

最佳答案

为声音文件的 URI 尝试这个

    import * as application from 'tns-core-modules/application';

const uri = new android.net.Uri.Builder()
.scheme(android.content.ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(application.android.nativeApp.getPackageName())
.appendPath("raw")
.appendPath("filename")
.build();

关于android - Nativescript 中的 RAW 文件(音频)文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54338035/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com