iOS media player package. Implemented in SwiftUI
using AVFoundation
.
Internal project focused on learning, training, and practicing media player development. Our goal is to build a feature-rich media player, akin to those found in commercial platforms like YouTube, using SwiftUI and other contemporary development practices. This project serves as a valuable resource for future reference, providing hands-on experience in media player creation for iOS platforms.
iOS 15.0
How to integrate with an existing project (SPM or CocoaPod)
Swift Package Manage(SPM):
- Add a new package via github, using the branch
main
CocoaPods:
- On your project create the
Podfile
bellow - Run
pod install
platform :ios, '15.0'
target 'SampleApp' do
pod 'EnhancedMediaPlayer', :git => 'https://github.com/profusion/ios-enhanced-media-player', :
branch => 'main'
end
The package supports remote and stream video and remote music. It's only necessary to provide the URL and the seekFactor. The URL consists in a URL of the media that will be loaded. And the seek factor consists in the value of the time interval in seconds to advance or rewind the media to be played with the forward and reward actions (with buttons or tapping the screen).
Here is an example of implementation:
import SwiftUI
import EnhancedMediaPlayer
struct ContentView: View {
static let seekFactor: TimeInterval = 10
static let urlExamples: URL = URL(string: "https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerJoyrides.mp4")!
var body: some View {
MediaPlayer(url: urlExample, seekFactor: seekFactor)
.frame(height: 300)
}
}
An example of implementation can be found in the ContentView.swift
file.
The project consists in a media player with the following features:
- Time bar (shows the passed and remaining time)
- Replay button
- Rewind and forward buttons or tapping the screen (with customized interval, the seek factor)
- Loop button (plays the video in loop when activated)
- Settings menu
- Support for SPM and CocoaPods integration