大佬教程收集整理的这篇文章主要介绍了Swift - 使用AVPlayer制作一个音乐播放器2(后台播放、操作、图片显示),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
var
window:
UIWindow
?
func
application(_ application:
UIApplication
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,didFinishLaunchingWithOptions
do {
try session.setActive(
@H_859_262@} catch {
true
)
print
(error)
}
return
true
}
applicationWillResignActive(_ application:
) {
}
}
}
applicationDidBecomeActive(_ application:
) {
}
applicationWillTerminate(_ application:
) {
}
}
|
UIViewController
weak
playButton:
UIButton
!
UILabel
!
AVPlayerItem
?
AVPlayer
?
viewDidLoad() {
.viewDidLoad()
AVPlayerItem
(url: url!)
(playerItem: playerItem!)
CMTime
= playerItem!.asset.duration
Float64
=
CMTimeGetSeconds
(duration)
(
.player!.currentTime())
Int
(currentTimE)
=all % 60
=
Int
(all/60)
f<10{
"0\(f):"
else
{
"0\(m)"
"暂停"
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
for
: .normal)
: .normal)
CMTimeMake
(seconds,1)
Bool
) {
NotificationCenter
.
default
.addObserver(
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,SELEctor: #SELEctor(finishedPlaying),
Nsnotification
.
Name
.
AVPlayerItemDidPlayToEndTime
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,object: playerItem)
.shared.beginReceivingRemoteControlEvents()
) {
)
"播放完毕!"
)
{
()
CGSize
(width: 400,height: 400)
UIImage
(named:
"cover"
)!
:
"我是歌曲标题"
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
@H_909_1162@mPMediaItemPropertyArtist
"hangge.com"
:1.5em!important; margin:0px!important; overflow:visible!important; padding:1px 0px!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-family:Consolas,
@H_687_1168@mPMediaItemPropertyArtwork
: albumArt,
@H_830_1173@mPNowPlayingInfoPropertyElapsedPlayBACkTime
: postion,
@H_180_1177@mPMediaItemPropertyPlayBACkDuration
: duration,
@H_189_1181@mPNowPlayingInfoPropertyPlayBACkRate
: playBACkState]
UIEvent
?) {
event = event
{
)
UIEventType
.remoteControl {
event.subtype {
.remoteControlTogglePlayPause:
)
)
)
以上是大佬教程为你收集整理的Swift - 使用AVPlayer制作一个音乐播放器2(后台播放、操作、图片显示)全部内容,希望文章能够帮你解决Swift - 使用AVPlayer制作一个音乐播放器2(后台播放、操作、图片显示)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。