iOS Question Display list of default ringtones in iOS

Filippo

Expert
Licensed User
Hi,

how can I create a list of all default ringtones?
 

Filippo

Expert
Licensed User
I've found something here. Is it possible to use, or are prohibited from apple?
B4X:
#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];
}
 
Upvote 0

Filippo

Expert
Licensed User
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
 
Upvote 0

moster67

Expert
Licensed User
Pity though...:(

I also just found out that it is not possible to call the standard iOS system icons to use for instance in a CustomListView as a bitmap. There are things which with Android we are taking for granted but simply aren't possible with iOS. Another example is that you cannot scan and list available wifi access-points (you can only get the one the device is currently connected to).
 
Upvote 0

Filippo

Expert
Licensed User
Yes, there are some things that are easier for Apple, but also many that are not possible. :cool::mad:
 
Upvote 0

ibra939

Active Member
Licensed User
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

Nice but this code to make ringtone for android? Will be great if that to change ringtone or to add in ringtone
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
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
 
Upvote 0

ibra939

Active Member
Licensed User
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 iam interesting to do that can we explain how we can create that will do it as wall
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Upvote 0

ibra939

Active Member
Licensed User
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

now iam creating media play with sharing with ringtone and i want add more feature then i will share it
 
Upvote 0

stevel05

Expert
Licensed User
Hi Narek,

Thanks for sharing the Media picker, unfortunately when I run it It returns null Url's for all audio files. Is this a permission thing? or could it have changed on ios 9.1?

Thanks

Steve
 
Upvote 0

stevel05

Expert
Licensed User
You may be right actually, I'll have to check that. Thanks for the quick response.
 
Upvote 0

stevel05

Expert
Licensed User
Yes that was it, working now. Thanks
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Hi Guys

Did anyone manage to have a working solution that allows selecting from the default ringtone list

Thanks in advance
 
Upvote 0

Hypnos

Active Member
Licensed User
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
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
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


Tap on the blank page and the mediapicker will appear.

I think that you can pass the URL received from the class to https://www.b4x.com/android/forum/t...playback-rate-pitch-change.78004/#post-494451) and play.

not tested but it should work

narek
 
Upvote 0
Top