欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

iOS鎖屏音頻 控制及音頻信息設(shè)置

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

iOS 后臺(tái)音頻 控制,鎖屏音頻 控制及音頻信息設(shè)置,效果圖如下:

 

1.在 AppDelegate.m 中實(shí)現(xiàn)下面方法,獲取音頻 、暫停、上一首、下一首點(diǎn)擊事件:

- (BOOL)canBecomeFirstResponder
{
 return YES;
}
 
//鎖屏界面控制監(jiān)聽
- (void)remoteControlReceivedWithEvent:(UIEvent *)event
{
 if (event.type == UIEventTypeRemoteControl) {
  switch (event.subtype) {
   case UIEventSubtypeRemoteControlPlay:
   {
    //      
    NSLog(@"Play");
    break;
   }
   case UIEventSubtypeRemoteControlPause:
   {
    //暫停
    NSLog(@"Pause");
    break;
   }
   case UIEventSubtypeRemoteControlNextTrack:
   {
    //下一首
    NSLog(@"Next");
    break;
   }
   case UIEventSubtypeRemoteControlPreviousTrack:
   {
    //上一首
    NSLog(@"Previous");
    break;
   }
   default:
    break;
  }
 }
}

2.設(shè)置鎖屏信息:

//設(shè)置鎖屏信息
- (void)setLockingInfo
{
 Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter");
 
 if (playingInfoCenter) {
  //音頻模型
  HWMusicModel *model = [HWMusicTool playingMusic];
  
  //數(shù)據(jù)信息
  NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init];
  
  //圖片
  MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageWithUrlString:model.icon]];
  [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork];
  
  //當(dāng)前      時(shí)間
  [songInfo setObject:[NSNumber numberWithDouble:[[[HWMusicTool shareMusicTool] Player] currentPlaybackTime]] forKey:MPNowPlayingInfoPropertyElapsedPlaybackTime];
  //速率
  [songInfo setObject:[NSNumber numberWithFloat:1.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate];
  //剩余時(shí)長(zhǎng)
  [songInfo setObject:[NSNumber numberWithDouble:[[[HWMusicTool shareMusicTool] Player] duration]] forKey:MPMediaItemPropertyPlaybackDuration];
  
  //設(shè)置標(biāo)題
  [songInfo setObject:model.title forKey:MPMediaItemPropertyTitle];
  
  //設(shè)置副標(biāo)題
  [songInfo setObject:@"周杰倫 - 周杰倫的床邊故事" forKey:MPMediaItemPropertyArtist];
  
  //設(shè)置音頻數(shù)據(jù)信息
  [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
 }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:C語言:利用指針編寫程序,用梯形法計(jì)算給定的定

欄    目:C語言

下一篇:Qt自定義控件實(shí)現(xiàn)圓圈加載進(jìn)度條

本文標(biāo)題:iOS鎖屏音頻 控制及音頻信息設(shè)置

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/50.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有