iOS Question Display list of default ringtones in iOS

D

Deleted member 103

Guest
Hi,

how can I create a list of all default ringtones?
 

Hypnos

Active Member
Licensed User
Longtime User
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
try to add this

B4X:
#PlistExtra:<key>NSMediaLibraryUsageDescription</key><string>description here...</string>

Thank you Narek for your quick reply and pointing me to the right direction. I am now able to see the picker by adding the following code:

#PlistExtra:<key>NSAppleMusicUsageDescription</key><string>Music Usage</string>

but now I'm trying to copy the music file from "URL" to dirDocuments, seems File.Copy command cannot use in this case, anyone know how to do please let me know.

Thanks so much!
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
No because I'm using Erel's inline obj c code and I know nothing about obj c, so I'm not able change it :(

It would be great if you or anyone can help me on it !


try this
B4X:
Sub mm_loaded(URL As String)
     PlaySound(URL, "", 1000, 0.5)
End Sub
 
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
try this
B4X:
Sub mm_loaded(URL As String)
     PlaySound(URL, "", 1000, 0.5)
End Sub

Hi narek,

I got this error:

B4X:
Application_Start
Application_Active
Canceled
ipod-library://item/item.mp3?id=137345610065094538
Error occurred on line: 54 (Main)
required condition is false: file != nil
Stack Trace: (
  CoreFoundation       <redacted> + 154
  libobjc.A.dylib      objc_exception_throw + 38
  CoreFoundation       <redacted> + 0
  AVFAudio             <redacted> + 64
  AVFAudio             <redacted> + 178
  SoundPitch           -[b4i_main playSound::::] + 842
  CoreFoundation       <redacted> + 68
  CoreFoundation       <redacted> + 294
  SoundPitch           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
  SoundPitch           -[B4INativeObject RunMethod::] + 158
SoundPitch           -[b4i_main _playsound::::] + 1908
SoundPitch           -[b4i_main _mm_loaded:] + 1086
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 294
SoundPitch           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
SoundPitch           -[B4IShell runMethod:] + 574
SoundPitch           -[B4IShell raiseEventImpl:method:args::] + 2212
SoundPitch           -[B4IShellBI raiseEvent:event:params:] + 1442
SoundPitch           -[B4ICommon CallSub4::::] + 332
SoundPitch           -[B4ICommon CallSub2::::] + 250
SoundPitch           -[b4i_mediapicker _audio_loaded::] + 1058
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 294
SoundPitch           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1784
SoundPitch           -[B4IShell runMethod:] + 574
SoundPitch           -[B4IShell raiseEventImpl:method:args::] + 2212
SoundPitch           -[B4IShellBI raiseEvent:event:params:] + 1442
SoundPitch           -[b4i_mediapicker mediaPicker:didPickMediaItems:] + 552
MediaPlayer          <redacted> + 142
MediaPlayer          <redacted> + 52
CoreFoundation       <redacted> + 68
CoreFoundation       <redacted> + 294
FrontBoardServices   <redacted> + 18
FrontBoardServices   <redacted> + 220
FrontBoardServices   <redacted> + 44
CoreFoundation       <redacted> + 12
CoreFoundation       <redacted> + 438
CoreFoundation       <redacted> + 762
CoreFoundation       CFRunLoopRunSpecific + 486
CoreFoundation       CFRunLoopRunInMode + 104
GraphicsServices     GSEventRunModal + 156
UIKit                <redacted> + 574
UIKit                UIApplicationMain + 150
SoundPitch           main + 106
libdyld.dylib        <redacted> + 2
)
 
Upvote 0

Hypnos

Active Member
Licensed User
Longtime User
This?

PlaySound("", URL, 1000, 0.5)

I got the same error.

and here is the related code:
B4X:
Sub PlaySound(Dir As String, FileName As String, Pitch As Int, rate As Double)
   Dim no As NativeObject = Me
   no.RunMethod("playSound::::", Array(File.Combine(Dir, FileName), Pitch, rate, engine))
End Sub

B4X:
#if OBJC
#import <AVFoundation/AVFoundation.h>
- (void) playSound: (NSString*) Path :(int)Pitch :(double)Rate :(AVAudioEngine*) engine{
   AVAudioFile* File = [[AVAudioFile alloc] initForReading: [NSURL fileURLWithPath: Path] error: nil];
   AVAudioPlayerNode* node = [AVAudioPlayerNode new];
   [node stop];
   [engine stop];
   [engine reset];
   [engine attachNode: node];
   AVAudioUnitTimePitch* changeAudioUnitTime = [AVAudioUnitTimePitch new];
   changeAudioUnitTime.rate = Rate;
   changeAudioUnitTime.pitch = Pitch;
   [engine attachNode: changeAudioUnitTime];
   [engine connect:node to: changeAudioUnitTime format: nil];
   [engine connect:changeAudioUnitTime to: engine.outputNode format:nil];
   [node scheduleFile:File atTime: nil completionHandler: nil];
   [engine startAndReturnError: nil];
   [node play];
}

#End If
 
Upvote 0
Top