小编enf*_*fix的帖子

记录.m4a文件Android

如何在Android 2.2中使用MediaRecorder 录制M4A 音频文件?
我需要设置什么输出格式,编码器和采样率?

我需要从麦克风录制它并将其保存在SDCARD中

UPDATE

我试过这段代码,但结果无效(例如在浏览器中没有播放):

recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // error here ?!?
recorder.setAudioSamplingRate(96000); // what value ?
Run Code Online (Sandbox Code Playgroud)

android m4a audio-recording

5
推荐指数
2
解决办法
8095
查看次数

iOS 通话后后台录音

我正在开发一个在后台录制音频的 iOS 应用程序。这工作很好。
问题是当有电话进来时:当我打电话时,应用程序停止录制(这很好),但是当通话结束时,我需要应用程序再次开始录制。

是否可以 ?我怎样才能做到这一点 ?

谢谢大家。

更新

我使用 AudioQueueNewInput 来录制音频。现在我尝试使用此代码来接听来电:

AVAudioSession *session = [AVAudioSession sharedInstance];
NSError *categoryError = nil;
[session setActive: NO error: nil];
if (![session  setCategory:AVAudioSessionCategoryPlayAndRecord
               withOptions:AVAudioSessionCategoryOptionMixWithOthers
                     error:&categoryError]){
    NSLog(@"Error"); //no error
}
[session setActive: YES error: nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(handleAudioSessionInterruption:)
                                             name:AVAudioSessionInterruptionNotification
                                           object:session];
Run Code Online (Sandbox Code Playgroud)

我可以通过 AVAudioSessionInterruptionOptionShouldResume 获取 handleAudioSessionInterruption 的通话结束,但是如何重新启动录音机?

我尝试使用再次调用 AudioQueueStart o 只是与我用来开始录制的功能相同的功能,但我看不到红色条(正在使用麦克风)来知道应用程序正在录制。怎么了 ?

audio-recording ios

5
推荐指数
1
解决办法
951
查看次数

Firebase云功能"admin.messaging(...).send不是功能"

我在Firebase Functions服务中有一个发送任何FCM的功能.我会使用admin.messaging().send()函数,就像这个参考指南一样,但是在触发函数时我得到了这个错误,而不是在部署期间:

TypeError: admin.messaging(...).send is not a function
   at exports.sendChatNotification.functions.database.ref.onCreate.event (/user_code/lib/index.js:113:30)
   at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:59:27)
   at next (native)
   at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:28:71
   at __awaiter (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:24:12)
   at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:53:36)
   at /var/tmp/worker/worker.js:700:26
   at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Run Code Online (Sandbox Code Playgroud)

我可以在功能 - >登录Firebase控制台中看到此错误.
那是我的功能代码:

 exports.sendChatNotification = functions.database.ref('/messages').onCreate(event => {

 var message = {
    data: {
        title: 'title',
        body: 'body',
    },
    apns: {
        header: {
            'apns-priority': '10',
            'apns-expiration':'0'
          },
        payload: {
            aps: {
                sound: 'default',
                'content-available':'1'
              }
        }
    },
    android: {
        ttl: 60*1000,
        priority: 'high'
      },
    topic: 'mytopic'
}; …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions firebase-cloud-messaging firebase-admin

5
推荐指数
1
解决办法
1638
查看次数

函数中的 Firebase 消息传递错误

在我的项目中,我使用 Firebase 函数通过 FCM 发送消息。我使用这个 API:

admin.messaging().send()
Run Code Online (Sandbox Code Playgroud)

最近而不是我用来调用它的所有令牌,我收到了这个错误:

Error: Requested entity was not found.
at FirebaseMessagingError.Error (native)
at FirebaseMessagingError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:39:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:85:28)
at new FirebaseMessagingError (/user_code/node_modules/firebase-admin/lib/utils/error.js:241:16)
at Function.FirebaseMessagingError.fromServerError (/user_code/node_modules/firebase-admin/lib/utils/error.js:271:16)
at /user_code/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:140:50
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Run Code Online (Sandbox Code Playgroud)

我该如何解决?我确定前段时间它可以工作,而这些错误则无效。
Firebase 有什么变化吗?

firebase google-cloud-functions firebase-cloud-messaging

5
推荐指数
1
解决办法
2462
查看次数

图像超过其他图像Android

如何在其他图像上设置图像(半透明)?
我需要创建新的位图,然后保存它.

谢谢大家.

android overlay bitmap

4
推荐指数
1
解决办法
3710
查看次数

错误@angular/fire构建错误地扩展了接口

我开始新的 Ionic/Angular 项目并添加 @Angular/Fire 包。
当我运行“ionicserve”时,出现以下错误:

Error: node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:18 - error TS2430: Interface 'DocumentSnapshotExists<T>' incorrectly extends interface 'DocumentSnapshot<DocumentData>'.
The types returned by 'data(...)' are incompatible between these types.
    Type 'T' is not assignable to type 'DocumentData | undefined'.
    Type 'T' is not assignable to type 'DocumentData'.

13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {

node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
    13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
    This type parameter might need an `extends firebase.firestore.DocumentData` constraint.
node_modules/@angular/fire/compat/firestore/interfaces.d.ts:13:41
    13 export interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot {
    This type parameter …
Run Code Online (Sandbox Code Playgroud)

angularfire ionic-framework angular

4
推荐指数
1
解决办法
5652
查看次数

如何从jar读取外部xml文件

我需要从 jar 可执行文件中的 java 应用程序读取外部 XML 文件。
如果我从控制台 (java -jar package.jar) 吃午饭它工作正常,但如果我通过双击 (Java Platform SE 二进制文件) 吃午饭它不起作用。
我有相对路径的这个问题。使用绝对路径,它可以双向工作。

java jar executable-jar

3
推荐指数
1
解决办法
7709
查看次数

按钮JSF中的绝对URL

我在标题中有这个按钮,我在很多页面中包含:

<input type="button" value="My Button" onclick="window.location.href='mypage.xhtml'"
Run Code Online (Sandbox Code Playgroud)

它使用相对路径,如果调用者页面在同一目录中,它就可以工作.如何使用绝对路径或使用commandButton标记?我尝试过:

/mypage.xhtml
Run Code Online (Sandbox Code Playgroud)

不工作(404错误)

javascript button jsf-2

2
推荐指数
1
解决办法
2579
查看次数

Android后退按钮和恢复活动

我有这个问题.
我有一个动作A启动其他活动B(通过onclick - 按钮).
我有一个后退按钮回来活性一个.我按它.
现在我在A,我再按一次按钮转到B.

如果我使用android后退按钮(我在B中)我首先回到A然后再回到B.
但是现在,如果我再次按下android后退按钮,我不会去A的previus活动或者它从app退出.我回到B !!!

我该如何防止这种行为?

android android-lifecycle android-activity

2
推荐指数
1
解决办法
3125
查看次数

从服务恢复android活动

我需要从后台服务重新启动我的主要活动.
我通过BroadcastReceiver得到了我的服务结果,我需要恢复它(在一些操作之后).

可能吗 ?
我怎样才能做到这一点 ?

我试过这个解决方案从通知恢复应用程序和堆栈,但它对我不起作用.

编辑:
那是我的接收器:

private BroadcastReceiver receiver = new BroadcastReceiver() {


        @Override
        public void onReceive(Context context, Intent intent) {
          Bundle bundle = intent.getExtras();
          if (bundle != null) {
            int resultCode = bundle.getInt(DownloadService.RESULT);
            if (resultCode == RESULT_OK) {
                Log.i("MyApp", "RESULT OK");
                final Intent mainIntent = new Intent(context, MainActivity.class);
                mainIntent.setAction(Intent.ACTION_MAIN);
                mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                startActivity(mainIntent);
            } else {
              Toast.makeText(MainActivity.this, "KO",Toast.LENGTH_LONG).show();
            }
          }
        }

 };
Run Code Online (Sandbox Code Playgroud)

android android-intent android-service

2
推荐指数
1
解决办法
3217
查看次数

Laravel assertJson 失败

我对这个测试有问题:

$this->json('POST', 'api/login')
        ->assertStatus(422)
        ->assertJson([
            'email' => ['The email field is required.'],
            'password' => ['The password field is required.'],
        ]);
Run Code Online (Sandbox Code Playgroud)

我不明白错误是什么:

Unable to find JSON: 

[{
    "email": [
        "The email field is required."
    ],
    "password": [
        "The password field is required."
    ]
}]

within response JSON:

[{
    "message": "The given data was invalid.",
    "errors": {
        "email": [
            "The email field is required."
        ],
        "password": [
            "The password field is required."
        ]
    }
}].


Failed asserting that an array has the …
Run Code Online (Sandbox Code Playgroud)

phpunit laravel

2
推荐指数
1
解决办法
1011
查看次数