0
我開發一個小音樂應用程序,其中第一視圖包括在泰伯維和歌曲所有的單子,當用戶點擊任意一個行(歌曲)需要他們第二種觀點&播放歌曲的(包括播放/暫停按鈕)。現在,我使用後退按鈕選擇第二個視圖的第一個視圖來選擇另一首歌曲。而且他們是首先查看一個按鈕,只需切換視圖(即它需要當前播放的歌曲),但是它扮演的是同一首歌從開始而不是從它的currentplaying。它類似於iOS中Stock音樂應用程序中的現在播放按鈕。 即時通訊使用故事板&塞格斯交換看法,並沒有辭退查看
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
temp = indexPath.row;
[tableView deselectRowAtIndexPath:indexPath animated:NO];
[self performSegueWithIdentifier:@"Player" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString:@"Player"])
{
MPMediaItem *item = [itemCollections objectAtIndex:temp];
NSString *trackInfo = [[NSString alloc] initWithFormat:@"%@- %@",[item valueForProperty:MPMediaItemPropertyTitle],[item valueForProperty:MPMediaItemPropertyArtist]];
MPMediaItemArtwork *artwork = [item valueForProperty:MPMediaItemPropertyArtwork];
NSURL *tempURL = [item valueForProperty:MPMediaItemPropertyAssetURL];
playerController = [segue destinationViewController];
playerController.fileUrl1 = tempURL;
playerController.globalVar = [NSNumber numberWithInteger:temp];
playerController.labelTitleString = trackInfo;
playerController.img = [artwork imageWithSize:CGSizeMake(100, 100)];
}
}
對不起,我無法理解這一點。其實我的應用程序委託正在處理所有的音樂播放。 –
我非常高興建議你不要使用你的AppDelegate。你的AppDelegate不是一些胖胖的單身人士;把這個邏輯放在它所屬的地方。 – John
同樣,我有這個代碼在app delegate.h @property(strong,nonatomic)AVAudioPlayer * audioPlayer; @property(nonatomic)NSInteger globalVar; @property(nonatomic,strong)NSMutableArray * itemm;我只有在應用程序委託聲明的一個實例,以便其容易讓我分享兩個 –