Nativescript 中的 RAW 文件(音频)文件夹 [英] RAW files (audio) folder in Nativescript

查看:65
本文介绍了Nativescript 中的 RAW 文件(音频)文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NativeScript 在打包应用时会自动考虑 raw 文件夹吗?

Is the raw folder automatically considered by NativeScript when packaging the app?

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

I could not find any reference to this. So what I'm trying to do is to store a .mp3 file in that folder and use it then as a custom notification sound.

问题是:那么我如何引用该文件?我应该写什么作为路径?这是相关的代码:

The problem is: How can I then reference that file? What should I write as a path? Here's the concerned code:

// 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();

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

Thanks in advance to anyone willing to help ❤️❤️

推荐答案

试试这个为声音文件的 URI

Try this for URI of sound file

    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();

这篇关于Nativescript 中的 RAW 文件(音频)文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆