Skip to main content
zasflower2014
Inspiring
March 21, 2019
Answered

Can AIR add Audio support set for ios?

  • March 21, 2019
  • 2 replies
  • 1219 views

i use Adobe AIR to develop a music player, use SampleDataEvent and FileStream AIR can play flac,wav,aiff,dsf,dff,aifc music files.
air audio decoder has done and it work great well.

but for ios , it can't show music info at ios control center (music part) and cant recive the next / prev pause / play button event at ios control center.
it is a big bug for music player.

can air team add this feature in AIR? just ios is OK.

or give a ANE for this.

thanks.

or open some function to set ios AVAudioSession and get ios control center music control button event.

just ios is OK.

Thanks very much.

This topic has been closed for replies.
Correct answer zasflower2014

i use ANE has done. show in ios music control center and dsp music sample at AIR use SampleDataEvent.

Thanks.

code:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:nil];

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

[[AVAudioSession sharedInstance] setActive:YES error:nil];

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

NSString *list = [productIdsString substringFromIndex:1];;

NSArray *listItems = [list componentsSeparatedByString:@"<ori>"];

NSMutableDictionary *songDict=[NSMutableDictionary dictionary];

NSString *tmpTitleStr = listItems[0];

//歌名

[songDict setObject:tmpTitleStr forKey:MPMediaItemPropertyTitle];

//歌手名

[songDict setObject:listItems[1] forKey:MPMediaItemPropertyArtist];

//歌曲的总时间

NSString *tmpTimeStr = listItems[2];

[songDict setObject:[NSNumber numberWithDouble:[tmpTimeStr doubleValue]] forKeyedSubscript:MPMediaItemPropertyPlaybackDuration];

//设置歌曲图片

// MPMediaItemArtwork *imageItem=[[MPMediaItemArtwork alloc]initWithImage:nil];

// [songDict setObject:imageItem forKey:MPMediaItemPropertyArtwork];

//设置控制中心歌曲信息

[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songDict];

2 replies

zasflower2014
zasflower2014AuthorCorrect answer
Inspiring
May 2, 2019

i use ANE has done. show in ios music control center and dsp music sample at AIR use SampleDataEvent.

Thanks.

code:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:nil];

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

[[AVAudioSession sharedInstance] setActive:YES error:nil];

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

NSString *list = [productIdsString substringFromIndex:1];;

NSArray *listItems = [list componentsSeparatedByString:@"<ori>"];

NSMutableDictionary *songDict=[NSMutableDictionary dictionary];

NSString *tmpTitleStr = listItems[0];

//歌名

[songDict setObject:tmpTitleStr forKey:MPMediaItemPropertyTitle];

//歌手名

[songDict setObject:listItems[1] forKey:MPMediaItemPropertyArtist];

//歌曲的总时间

NSString *tmpTimeStr = listItems[2];

[songDict setObject:[NSNumber numberWithDouble:[tmpTimeStr doubleValue]] forKeyedSubscript:MPMediaItemPropertyPlaybackDuration];

//设置歌曲图片

// MPMediaItemArtwork *imageItem=[[MPMediaItemArtwork alloc]initWithImage:nil];

// [songDict setObject:imageItem forKey:MPMediaItemPropertyArtwork];

//设置控制中心歌曲信息

[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songDict];

Flipline
Inspiring
March 22, 2019

Have you tried the Media Player ANE by distriqt?  It looks like it can display music info in the control center and also register for control center events:

MediaPlayer by distriqt

zasflower2014
Inspiring
March 22, 2019

I need use air sound to output and need use as3 dsp sound.not by apple itself. Sound is better than apple.need use air sound.

Flipline
Inspiring
March 22, 2019

Yes, but looking at the documentation for the ANE, the control center functionality seems to be separate from the actual media player.  You could try using the ane ONLY for the control center code and use your own player code, ignoring the media player code in the ANE if you only want access to control center.