//
//  RNAudioPlayer.m
//  humand
//
//  Created by Oleksandr Shumihin on 26/11/25.
//  Copyright © 2025 Humand. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import "Humand-Swift.h"

@interface RNAudioPlayer : NSObject <RCTBridgeModule>
@end

@implementation RNAudioPlayer
RCT_EXPORT_MODULE(RNAudioPlayer);

RCT_EXPORT_METHOD(play
                  : (RCTPromiseResolveBlock)resolve reject
                  : (RCTPromiseRejectBlock)reject) {
  [HumandAudioPlayer.shared play:resolve reject:reject];
}

RCT_EXPORT_METHOD(pause
                  : (RCTPromiseResolveBlock)resolve reject
                  : (RCTPromiseRejectBlock)reject) {
  [HumandAudioPlayer.shared pause:resolve reject:reject];
}

RCT_EXPORT_METHOD(seekTo : (nonnull NSNumber*)seconds) {
  [HumandAudioPlayer.shared seekTo:seconds];
}

RCT_EXPORT_METHOD(setPlaybackRate : (nonnull NSNumber*)rate) {
  [HumandAudioPlayer.shared setPlaybackRate:rate];
}

RCT_EXPORT_METHOD(replace
                  : (NSDictionary*)options resolve
                  : (RCTPromiseResolveBlock)resolve reject
                  : (RCTPromiseRejectBlock)reject) {
  [HumandAudioPlayer.shared replace:options resolve:resolve reject:reject];
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getState) {
  return [HumandAudioPlayer.shared getState];
}

RCT_EXPORT_METHOD(reset) {
  [HumandAudioPlayer.shared reset];
}

@end
