• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

How can i use AIR show music info at ios music center?

Explorer ,
Nov 16, 2017 Nov 16, 2017

Copy link to clipboard

Copied

I has use AIR 24 for develop a advanced music player on AppStore.and it is online about one year.it can use air to play flac,wav,mp3,dsf,dff file.
this app,it was developed by Adobe AIR:
K Music Player HiEnd Ultimate on the App Store


and how can i show music info at ios music center and get the pause, play,next music control event?

like this:

392x696bb.jpgI

TOPICS
Air beta

Views

646

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

Can AIR Team fix this bug?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

It's very important. a music player must use this function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

LATEST

I Try to use ANE do this ,but not worked:

//后台播放音频设置

AVAudioSession *session = [AVAudioSession sharedInstance];

[session setActive:YES error:nil];

[session setCategory:AVAudioSessionCategoryPlayback error:nil];

//让app支持接受远程控制事件

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];

- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {

    if (receivedEvent.type == UIEventTypeRemoteControl) {

       

        switch (receivedEvent.subtype) {

               

            case UIEventSubtypeRemoteControlTogglePlayPause:

                NSLog(@"UIEventSubtypeRemoteControlTogglePlayPause");

                // [self playAndStopSong:self.playButton];

                if (self.playback && self.playback.isPlaying) {

                    [self.playback pause];

                } else if (self.playback && !self.playback.isPlaying) {

                    if(_playCount==0){

                        [self playNextMusic];

                    }else{

                        [self.playback play];

                    }

                }

               

                if(_isPlayed==false){

                    [self playNextMusic];

                }

                break;

               

            case UIEventSubtypeRemoteControlPreviousTrack:

                NSLog(@"UIEventSubtypeRemoteControlPreviousTrack");

                //[self playLastButton:self.lastButton];

                [self playPrevMusic];

                break;

               

            case UIEventSubtypeRemoteControlNextTrack:

                NSLog(@"UIEventSubtypeRemoteControlNextTrack");

                //[self playNextSong:self.nextButton];

                [self playNextMusic];

                break;

               

            case UIEventSubtypeRemoteControlPlay:

                NSLog(@"UIEventSubtypeRemoteControlPlay");

                //[self playAndStopSong:self.playButton];

                if (self.playback && self.playback.isPlaying) {

                    [self.playback pause];

                } else if (self.playback && !self.playback.isPlaying) {

                    if(_playCount==0){

                        [self playNextMusic];

                    }else{

                        [self.playback play];

                    }

                }

                break;

               

            case UIEventSubtypeRemoteControlPause:

                NSLog(@"UIEventSubtypeRemoteControlPause");

                if (self.playback && self.playback.isPlaying) {

                    [self.playback pause];

                } else if (self.playback && !self.playback.isPlaying) {

                    [self.playback play];

                }

                //[self playAndStopSong:self.playButton];

                break;

               

            default:

                break;

        }

    }

}

-(void)configNowPlayingInfoCenter{

   

    if (NSClassFromString(@"MPNowPlayingInfoCenter")) {

        //NSDictionary *info = [self.musicList objectAtIndex:_playIndex];

        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

       

        [dict setObject:_infoNowName forKey:MPMediaItemPropertyTitle];

       

        [dict setObject:@"CC Music Player" forKey:MPMediaItemPropertyArtist];

       

        [dict setObject:@"Hi-Res Audio" forKey:MPMediaItemPropertyAlbumTitle];

       

        if(_musicfullPath != nil && _musicfullPath.length !=0){

        NSRange range;

        range = [_musicfullPath rangeOfString:@"."];

        if (range.location != NSNotFound) {

            NSString *newStr = [_musicfullPath substringToIndex:range.location+1];

            NSLog(@"found at location = %@",newStr);

           

            NSString *filePath = [newStr stringByAppendingString:@"jpg"];

            NSFileManager *fm = [NSFileManager defaultManager];

            if ([fm fileExistsAtPath:filePath]) {

                NSData * data = [NSData dataWithContentsOfFile:filePath];

                UIImage *image = [UIImage imageWithData:data];

                //return image;

               

                MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc] initWithImage:image];

                [dict setObject:artwork forKey:MPMediaItemPropertyArtwork];

            }else{

                NSRange range8;

                range8 = [_musicfullPath rangeOfString:@"/" options:NSBackwardsSearch];

                if (range8.location != NSNotFound) {

                    NSString *newStr8 = [_musicfullPath substringToIndex:range8.location+1];

                    //NSLog(@"found at location = %@",newStr);

                   

                    NSString *filePath8 = [newStr8 stringByAppendingString:@"Cover.jpg"];

                    NSFileManager *fm8 = [NSFileManager defaultManager];

                    if ([fm8 fileExistsAtPath:filePath8]) {

                        NSData * data8 = [NSData dataWithContentsOfFile:filePath8];

                        UIImage *image8 = [UIImage imageWithData:data8];

                        //return image;

                       

                        MPMediaItemArtwork *artwork8 = [[MPMediaItemArtwork alloc] initWithImage:image8];

                        [dict setObject:artwork8 forKey:MPMediaItemPropertyArtwork];

                    }

                    //UIImage *image = [UIImage imageNamed:[info objectForKey:@"image"]];

                }else{

                    NSLog(@"Not Found");

                }

            }

            //UIImage *image = [UIImage imageNamed:[info objectForKey:@"image"]];

        }else{

            NSLog(@"Not Found");

           

          

        }

        }

        [dict setObject:[NSNumber numberWithDouble:_mavMusicLen/1000.0f] forKey:MPMediaItemPropertyPlaybackDuration];

       

        [dict setObject:[NSNumber numberWithDouble:0.0f] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];

       

        [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:dict];

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines