D
Deleted member 103
Guest
Hi,
how can I create a list of all default ringtones?
how can I create a list of all default ringtones?
#import <MediaPlayer/MediaPlayer.h>
- (IBAction) AddMusicOrShowMusic: (id) sender
{
MPMediaPickerController *picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = NO;
picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker");
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES];
[self presentViewController:picker animated:YES completion:NULL];
[picker release];
}
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
[self dismissViewControllerAnimated:YES completion:nil];
item = [[mediaItemCollection items] objectAtIndex:0];
NSURL *url = [item valueForProperty:MPMediaItemPropertyAssetURL];
NSLog(@"url : %@",url);
}
- (void) mediaPickerDidCancel: (MPMediaPickerController *) mediaPicker
{
[self dismissViewControllerAnimated:YES completion:nil];
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated: YES];
}
list1.Initialize
If File.Exists("/system/media/audio","ringtones") Then
list1.Clear
list1.AddAll(File.ListFiles("/system/media/audio/ringtones"))
list1.Sort(True)
For i = 0 To list1.Size -1
str=list1.get(i)
If str.Contains(".") AND str.Length>1 Then
spnAlarm.Add(str.SubString2(0,str.LastIndexOf(".")))
lstSound.Add("/system/media/audio/ringtones/" & list1.get(i))
End If
Next
End If
Too bad, in android it was so easy with the code:
B4X:list1.Initialize If File.Exists("/system/media/audio","ringtones") Then list1.Clear list1.AddAll(File.ListFiles("/system/media/audio/ringtones")) list1.Sort(True) For i = 0 To list1.Size -1 str=list1.get(i) If str.Contains(".") AND str.Length>1 Then spnAlarm.Add(str.SubString2(0,str.LastIndexOf("."))) lstSound.Add("/system/media/audio/ringtones/" & list1.get(i)) End If Next End If
Actually I have managed to create a class (without library )which will let you open media picker, chose a song and play the song with your mediaplayer but I dont know if it can show the ringtones.
If someone interested let me know.
Narek
Please see attached project
simple demo
this is just returning the URL of the media.
with some hook you can have all the info (name,duration,...)
narek
I didnt understood what u are creating but anyway great)
if you will need some help let me know.
To play the song loaded with MediaPicker you need to init a AVAudioPlayer with OBJC.
Narek
Please see attached project
simple demo
this is just returning the URL of the media.
with some hook you can have all the info (name,duration,...)
narek
Hello Narek,
I tried your demo and run on my iPhone but I can only see a blank page, can you please let me know how to use your class in more details? I want to use the mediapicker to select a song file and save it into dirDocuments in order to play the song with pitch changed. (please refer to https://www.b4x.com/android/forum/t...playback-rate-pitch-change.78004/#post-494451)
Not sure your class can help on it?
Thank you!
Simon