Open the new MLAudioPlayer folder, and drag the MLAudioPlayer.xcodeproj into the Project Navigator of your application’s Xcode project.
It should appear nested underneath your application’s blue project icon. Whether it is above or below all the other Xcode groups does not matter.
Select the MLAudioPlayer.xcodeproj in the Project Navigator and verify the deployment target matches that of your application target.
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the + button under the “Embedded Binaries” section.
You will see two different MLAudioPlayer.xcodeproj folders each with two different versions of the MLAudioPlayer.framework nested inside a Products folder.
It does not matter which Products folder you choose from.
Select the MLAudioPlayer.framework.
And that’s it!
The MLAudioPlayer.framework is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the + button under the “Embedded Binaries” section.
Add the downloaded MLAudioPlayer.framework.
And that’s it!
Usage
You need these images files with named in your Assets
play
pause
refresh
playerLoad
thumbTracking
import MLAudioPlayer
//Default Sizes
//MLAudioPlayer.widthPlayerMini = UIScreen.main.bounds.width
//MLAudioPlayer.heightPlayerMini = CGFloat(216)
// For playing stream/online files
var mlAudioPlayer: MLAudioPlayer = {
// For playing the stream/online files
let mlAudioPlayer = MLAudioPlayer(urlAudio: "http://urlyouraudio.mp3")
return mlAudioPlayer
}()
// For playing local storage files
var mlLocalAudioPlayer: MLAudioPlayer = {
// For playing the stream/online files
let mlAudioPlayer = MLAudioPlayer(urlAudio: "file://urlyourlocalaudio.mp3", isLocalFile: true)
return mlAudioPlayer
}()
//Default Sizes
//MLAudioPlayer.widthPlayerFull = UIScreen.main.bounds.width
//MLAudioPlayer.heightPlayerFull = CGFloat(80)
var mlAudioPlayerMini: MLAudioPlayer = {
var config = MLPlayerConfig()
config.loadingText = "carregando"
config.playerType = .mini
config.tryAgainText = "TENTAR NOVAMENTE"
let mlAudioPlayerMini = MLAudioPlayer(urlAudio: "http://urlyouraudio.mp3", config: config)
return mlAudioPlayerMini
}()
//Can you listenign a player heightConstraint changes
mlAudioPlayer.didUpdateHeightConstraint = { constant in
print("heightConstraint changed"
}
Start loading after…
In some cases it is necessary to delay loading the audio until some other screen loading for example is completed. for these cases it is possible to configure the player in this way.
//set autoload to false
let mlAudioPlayer = MLAudioPlayer(urlAudio: "http://youraudio.mp3",
config: nil,
isLocalFile: false, autoload: false)
/**
Example: Loading after using
Post to .MLAudioPlayerNotification userInfo = ["action": MLPlayerActions.load]
*/
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
NotificationCenter.default.post(name: .MLAudioPlayerNotification, object: nil,
userInfo: ["action": MLPlayerActions.load])
}
On viewWillAppear Player starting load
MLPlayerConfig
Can you change any configuration on MLPlayerConfig
Properties to change infos on lock screen
class MLAudioPlayer {
/// Define a Title Audio to show in block Screen
public var titleAudio = ""
/// Define a Title for album to show in lock Screen
public var titleAlbum = ""
/// Define a artist name to show in lock Screen
public var artistName = ""
/// Define a artwork to show in block Screen
public var artwork: UIImage?
/// Contains a current time audio
public var currentTime: Double = 0.0
}
MLAudioPlayer
AudioPlayer for Swift projects
Requirements
Installation
Dependency Managers
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
To integrate MLAudioPlayer into your Xcode project using CocoaPods, specify it in your
Podfile
:Then, run the following command:
Carthage
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
To integrate MLAudioPlayer into your Xcode project using Carthage, specify it in your
Cartfile
:Swift Package Manager
To use MLAudioPlayer as a Swift Package Manager package just add the following in your Package.swift file.
Manually
If you prefer not to use either of the aforementioned dependency managers, you can integrate MLAudioPlayer into your project manually.
Git Submodules
cd
into your top-level project directory, and run the following command “if” your project is not initialized as a git repository:Open the new
MLAudioPlayer
folder, and drag theMLAudioPlayer.xcodeproj
into the Project Navigator of your application’s Xcode project.Select the
MLAudioPlayer.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target.Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the “Targets” heading in the sidebar.
In the tab bar at the top of that window, open the “General” panel.
Click on the
+
button under the “Embedded Binaries” section.You will see two different
MLAudioPlayer.xcodeproj
folders each with two different versions of theMLAudioPlayer.framework
nested inside aProducts
folder.Select the
MLAudioPlayer.framework
.And that’s it!
Embedded Binaries
+
button under the “Embedded Binaries” section.MLAudioPlayer.framework
.Usage
You need these images files with named in your Assets
Start loading after…
In some cases it is necessary to delay loading the audio until some other screen loading for example is completed. for these cases it is possible to configure the player in this way.
On
viewWillAppear
Player starting loadMLPlayerConfig
Can you change any configuration on MLPlayerConfig
Properties to change infos on lock screen
See available configurations:
Using Notification Center
Usage:
Available Actions for MLAudioPlayer
Can you change the images names
Demo
On this project change target for MLAudioPlayerDemo Build and Run
Docs
See Documentation
MLAudioPlayer Docs (46% documented)
Contributing
Issues and pull requests are welcome!
Todo
Author
Michel Anderson Lutz Teixeira @michel_lutz
Contributions
License
MLAudioPlayer is released under the MIT license. See LICENSE for details.