An advanced media player library, simple and reliable

Related tags

Audio player media
Overview

SRG Media Player logo

GitHub releases platform SPM compatible GitHub license

About

The SRG Media Player library provides a simple way to add universal audio / video playback support to any application. It provides:

  • A controller with precise playback state information and and a simple but powerful playback API.
  • Automatic integration with AVPlayerViewController.
  • A set of overlays which can be combined to create custom player user interfaces.
  • Support for subdivision of medias in (non-overlapping) sequences, which can provide am additional finer-grained playback structure or block playback to parts of the content.
  • Support for on-demand, live and DVR streams.
  • Support for 360° and cardboard playback.
  • Ability to use several instances of the player at the same time.

Compatibility

The library is suitable for applications running on iOS 9, tvOS 12 and above. The project is meant to be compiled with the latest Xcode version.

Contributing

If you want to contribute to the project, have a look at our contributing guide.

Integration

The library must be integrated using Swift Package Manager directly within Xcode. You can also declare the library as a dependency of another one directly in the associated Package.swift manifest.

Usage

When you want to use classes or functions provided by the library in your code, you must import it from your source files first. In Objective-C:

@import SRGMediaPlayer;

or in Swift:

import SRGMediaPlayer

Working with the library

To learn about how the library can be used, have a look at the getting started guide.

Logging

The library internally uses the SRG Logger library for logging, within the ch.srgssr.mediaplayer subsystem. This logger either automatically integrates with your own logger, or can be easily integrated with it. Refer to the SRG Logger documentation for more information.

Control preview in Interface Builder

Interface Builder can render custom controls dropped onto a storyboard or a xib. If you want to enable this feature for SRG Media Player controls, copy the SRGMediaPlayerDesignables.m file available from the Swift Package Manager checkout to your project and add it to your target.

When dropping a media player control (e.g. SRGPictureInPictureButton) onto a storyboard or xib, Xcode will now build your project in the background and render the view when it is done.

Remark

Since the SRGMediaPlayerDesignables.m must be copied to your project, you should update this file when updating the SRG Media Player library.

Demo project

To test what the library is capable of, run the associated demo.

License

See the LICENSE file for more information.

You might also like...
Fully functional music player which is written in swift programming language
Fully functional music player which is written in swift programming language

Music Player Source Code Fully functional Music Player Application Source code that is written in Swift 4.1, Xcode 9.3 Introduction Music Player for i

Stem Player - An iOS app that can manipulate song stems.
Stem Player - An iOS app that can manipulate song stems.

Stem Player is an iOS app that can manipulate song stems

Stem Player is an iOS app that can manipulate song stems
Stem Player is an iOS app that can manipulate song stems

Stem Player Stem Player is an iOS app that can manipulate song stems. Demo Start Screen Add Song Stem Player How it works Stem Player is an iOS app th

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way. You can play

SwiftySound is a simple library that lets you deal with Swift sounds easily

SwiftySound Overview SwiftySound is a simple library that lets you deal with Swift sounds easily. Static methods Sound.play(file: "dog.wav") Sound.pla

SimplePlayer - A simple application to fetch songs from iTunes Library by searching song's artist

SimplePlayer is a simple application to fetch songs from iTunes Library by searching song's artist.

AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.
AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.

AudioPlayer AudioPlayer is a simple class for playing audio in iOS, macOS and tvOS apps.

SoundManager - A simple framework to load and play sounds in your app.

SoundManager - A simple framework to load and play sounds in your app.

TuningFork is a simple utility for processing microphone input and interpreting pitch, frequency, amplitude, etc.
TuningFork is a simple utility for processing microphone input and interpreting pitch, frequency, amplitude, etc.

Overview TuningFork is a simple utility for processing microphone input and interpreting pitch, frequency, amplitude, etc. TuningFork powers the Parti

Releases(7.1.0)
  • 7.1.0(Aug 11, 2022)

    • The minimum deployment target has been bumped to iOS 12.
    • This release makes sure the project builds with Xcode 14 without any significant warning.
    • Restore Catalyst support with Xcode 14 (#105).
    Source code(tar.gz)
    Source code(zip)
  • 7.0.3(Jul 18, 2022)

  • 7.0.2(Jul 8, 2022)

    • When no subtitles have been explicitly enabled, forced subtitles matching the currently selected audio language are automatically displayed.
    Source code(tar.gz)
    Source code(zip)
  • 7.0.1(May 20, 2022)

  • 7.0.0(Apr 13, 2022)

    New features

    • The controller supports the rates 0.5×, 0.75×, 1×, 1.25×, 1.5×, 2× for slow, normal or fast playback. These supported values are returned from the supportedPlaybackRates property and the desired rate can be set using the newly available playbackRate property.
    • Livestreams might not always support some playback speeds. The effectivePlaybackRate property returns the currently applied playback rate.
    • On iOS:
      • The track selection button has been transformed into a settings button from which playback speed, audio track and subtitles can be selected.
      • The settings button is visible at all times, not only when subtitles are available. The subtitle selection state is similarly not reflected anymore by the button itself.
      • The button delegate protocol provides new methods called when the user picks a playback speed, audio track or subtitles.
    • On tvOS:
      • Playback speed can be selected using a dedicated button available from SRGMediaPlayerViewController main user interface.
      • The SRGMediaPlayerViewControllerDelegate protocol provides a new delegate method called when the playback speed is changed (no similar methods are provided for audio or subtitle track selection for technical reasons, though).

    Improvements

    • Playback setting window colors have been tweaked for better readability.
    • Add slider dragging start and strop delegate methods to SRGTimeSliderDelegate.
    • Add support for slider increment and decrement accessibility gestures (#116).

    Fix

    • Fix tvOS 15 crashes when playing another media.

    Breaking changes

    • SRGTracksButton has been renamed as SRGPlaybackSettingsButton.
    • The alwaysHidden playback settings button property has been removed, as the button is now always visible. Simply use the hidden property when you need to hide the button.
    • The selectedImage playback settings button property has been removed, as there is no selected state anymore.
    • SRGTracksButtonDelegate has been renamed as SRGPlaybackSettingsButtonDelegate. Existing method signatures have been updated appropriately.

    Migration instructions

    If you were previously using SRGTracksButton:

    • Update any code or resource (storyboard, xib) explicitly referencing the SRGTracksButton class, replacing it with SRGPlaybackSettingsButton.
    • Update the SRGMediaPlayerDesignables.m file if you were using it by copying the updated file available from the Designables source code folder.
    • Replace calls to alwaysHidden with hidden.
    • Update your button delegate protocol implementation to SRGPlaybackSettingsButtonDelegate.
    Source code(tar.gz)
    Source code(zip)
  • 6.2.2(Mar 14, 2022)

  • 6.2.1(Dec 16, 2021)

  • 6.2.0(Dec 10, 2021)

    • Picture in picture is now a controller opt-in, enabled with the pictureInPictureEnabled property. This fixes an issue appeared with iOS 14, and which could lead to picture in picture enabled unnecessarily when moving the app to the background (#111).
    Source code(tar.gz)
    Source code(zip)
  • 6.1.5(Nov 2, 2021)

    This release fixes two regressions experienced on iOS 15:

    • Fix SRGMediaPlayerViewBackgroundBehaviorDetachedWhenDeviceLocked view behavior so that playback correctly continues when the device is locked while the view is still visible.
    • The picture in picture overlay stays visible when locking the device (playback continues on iOS 15 but pauses on earlier versions of iOS).
    Source code(tar.gz)
    Source code(zip)
  • 6.1.4(Sep 22, 2021)

  • 6.1.3(Jun 23, 2021)

  • 6.1.2(Jan 6, 2021)

  • 6.1.1(Dec 11, 2020)

  • 6.1.0(Nov 24, 2020)

  • 6.0.0(Oct 23, 2020)

    Improved iOS and tvOS 14 compatibility

    This release improves compatibility with iOS and tvOS 14, most notably:

    • The time slider appearance has been fixed when displayed on a modal with a custom transition animation.
    • A potential route detection deadlock has been fixed.
    • Picture in picture is available for tvOS.

    Note that background video playback does not work on iOS 14.0 and 14.1 because of an iOS bug. This bug will be fixed in iOS 14.2 without requiring any SRG Media Player update.

    Source code(tar.gz)
    Source code(zip)
  • 5.0.3(Sep 19, 2020)

    Apple took us by surprise this year. We had reported an iOS 14 regression (player leak due to PiP changes in iOS 14), but this bug was not addressed and iOS 14 released. As a result, playing a video on iOS 14 with SRGMediaPlayerController is internally leaking an AVPlayer instance for reasons outside our control.

    This release provides a workaround for this issue until we can discuss with Apple about it (if we ever can). It first internally presents an invisible AVPlayerViewController instance, which magically fixes the issue.

    About Xcode 12 support

    A proper iOS / tvOS 14 release will be made later. Until then, we recommend you ship your application with Xcode 11.7 if you can. The library can be compiled with Xcode 12 but has not been fully tested yet.

    If you still intend to use Xcode 12, note there is an issue with Carthage with a workaround available. The next official release we will deliver will support Xcode 12 and replace Carthage with SPM.

    Known issues

    iOS 14 breaks background video playback support. This is either desired behavior or a regression. Until we know more the API will be kept as is but will not produce the expected behavior (video playback is paused when transitioning to the background, even if the player layer is detached).

    Finally, note that picture in picture is not working for tvOS 14 yet. This feature is planned for a later release.

    Source code(tar.gz)
    Source code(zip)
  • 5.0.2(Sep 1, 2020)

  • 5.0.1(Sep 1, 2020)

    • Fix stall detection, avoiding the controller to sometimes stay stuck in this state.
    • Avoid screen dimming when playing a video with sound routed over AirPlay.
    • Correctly take into account SDH accessibility opt-in when choosing subtitles automatically.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Jul 8, 2020)

    Date support

    This release adds support for dates when playing a livestream:

    • When playing a livestream, the currentDate property of SRGMediaPlayerController provides the date corresponding to the current position, if any.
    • For livestreams the player can equivalently start playback or seek to time or date-based positions. New SRGMark and SRGMarkRange classes have been introduced to support this duality.
    • (Breaking change) To support the time / date duality, segments are not defined anymore with time ranges, but with mark ranges. The previously required -srg_timeRange property has therefore been replaced with -srg_markRange.
    • (Breaking change) SRGTimeSliderDelegate methods receive an optional date parameter. Be sure your implementation adopt the new method signatures.

    This feature works best if date information is supplied in the streams themselves with EXT-X-PROGRAM-DATE-TIME tags. This ensures that the stream time and the wall-clock time can be related. If no such information is available in your streams you can still use date-based seeking, but accuracy might not be optimal (there is a delay between broadcasting and streaming). To mitigate this issue, you can measure which delay there is between broadcasting and streaming, and provide a SRGMediaPlayerUserInfoStreamOffsetKey as userInfo when playing your stream.

    Fixes

    • Ensure the player prevents the device from sleeping only when required. For video background playback proper behavior requires a device supporting iOS 12 or above.
    • Fix imprecise seeks when a Bluetooth handset is connected.
    • Fix issue preventing the player from correctly resuming when seeking outside the available media range.
    • Fix tvOS build issue with Xcode 11.4.
    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Mar 9, 2020)

    Audio tracks and subtitle support

    Audio track and subtitle support has been greatly improved to be more consistent and user-friendly.

    iOS and tvOS

    • Default audio selection now takes the application language into account, as well as user preferred languages. For example, if an application is only translated in French but offers content with French and English audio, the default language is now French. Previously, this depended only on user preferred languages and could be English if the user preferred language was English, even though the application was available in French only.
    • Automatic subtitle selection works as it should. It now correctly automatically enables subtitles if the audio is not a language the user is supposed to understand, but that subtitles the user can understand are available (based on app and system preferred languages).
    • Media configuration could be made programatically by assigning a block to the mediaConfigurationBlock. This single block has been replaced with two specific audioConfigurationBlock and subtitleConfigurationBlock blocks. Refer to the updated documentation to see how these blocks should be implemented so that you can update your code appropriately.
    • Subtitle styling was previously made with the mediaConfigurationBlock. It must now be made with the new dedicated textStyleRules controller property.
    • The -reloadMediaConfigurationWithBlock: and -reloadPlayerConfigurationWithBlock: controller methods have been removed. If you need to update a configuration block and apply the changes, update the associated block property and call -reloadMediaConfiguration or -reloadPlayerConfiguration afterwards.

    iOS only

    • Audio track and subtitle choices are correctly preserved when casting over AirPlay and not overridden by the receiver (e.g. Apple TV) anymore.
    • The audio track and subtitle user interface has been improved. The current choice is always displayed (even if not available for the specified content). Empty selection is not possible anymore (this was clearly misleading for users) and information to the user has been improved.
    • Empty subtitle tracks are now omitted. This avoids SRGTracksButton from being displayed when not needed, and eliminates dumb choices with no visible effect from the tracks popover altogether.

    Other changes

    A few fixes and improvements have been made as well.

    iOS and tvOS

    • Player and UI component energy efficiency has been improved (the number of refreshes has been reduced). In particular, non-required background activity has been eliminated.

    iOS only

    • SRGPlaybackButton can be assigned an optional delegate for action and accessibility customization if needed.
    • Picture in picture and AirPlay play along in a more natural way. When PiP is enabled, external playback is now prevented automatically (only audio might is routed to the receiver).
    • Documentation for PiP support has been improved. In particular, correct restoration requires a custom transition to be implemented which was previously not clearly stated. Refer to the documentation and examples for more information.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Dec 17, 2019)

    • The library is compatible with tvOS.
    • Many properties are now key-value observable (e.g. timeRange or mediaType). If your implementation previously used periodic time observers to check these properties for changes, you should now simply respond to changes instead.
    • The AirPlay button now supports two different images for audio and video. The previously unique image property has been removed.
    • Semantic versioning has been adopted.
    • The project has been renamed as srgmediaplayer-apple.
    Source code(tar.gz)
    Source code(zip)
  • 2.8(Aug 13, 2019)

    • The project has been updated to support iOS 13 and Xcode 11.
    • The track selection interface has been updated:
      • Dark mode is supported on iOS 13 and above. A new userInterfaceStyle property for SRGTracksButton lets you choose whether the appearance is controlled by the system, or whether the track selection interface should always be displayed with a light or dark theme.
      • The track selection interface displays either as a popover or modal depending on the available screen width.
    • The SRGMediaPlayerViewController icons have been updated for a more consistent look & feel.
    • The SRGTracksButtonDelegate delegate methods have been renamed.
    Source code(tar.gz)
    Source code(zip)
  • 2.7.1(Jul 29, 2019)

  • 2.7(Jul 5, 2019)

    • Background video playback behavior can be finely controlled with the viewBackgroundBehavior controller property. If you want to allow lock screen playback on devices running iOS 12.3 and above (the standard behavior of SRGMediaPlayerController until version 2.6), use SRGMediaPlayerViewBackgroundBehaviorDetachedWhenDeviceLocked.
    • Fix an issue with Akamai streams containing subtitles when start and / or end times are provided (playback not ending correctly because of subtitles longer than the stream).
    • Route detection and AirPlay button layout performance have been improved on iOS 11 and above.
    Source code(tar.gz)
    Source code(zip)
  • 2.6(Jun 7, 2019)

    • Support for subtitle selection has been improved to better take Accessibility settings (SDH / Audio description) into account, as well as user preferred languages.
    • A media configuration block can be optionally be attached to a media player controller. This block is called when a media is ready to play, and provides a convenient way to customize the AVPlayerItem before it is played. This block is mostly provided as a way to customize subtitle and audio tracks programatically (#64).
    • Playback methods which expected an AVPlayerItem object now expect an AVURLAsset object instead. Accordingly, the SRGMediaPlayerPreviousPlayerItemAssetKey constant has been renamed as SRGMediaPlayerPreviousURLAssetKey.
    • Player stalls are now reported in a reliable way.
    • Audio-only playback detection has been improved (#63).
    • A new SRGMediaPlayerPreviousSelectedSegmentKey is supplied in playback state change notifications to provide information about any previously selected segment.
    • The subtitle popover style cannot be overridden anymore with UIAppearance.
    • The framework footprint at application startup time has been reduced.
    Source code(tar.gz)
    Source code(zip)
  • 2.5.6(Mar 19, 2019)

  • 2.5.5(Mar 19, 2019)

    • Subtitle support has been improved (#58):
      • The behavior of subtitle selection closely matches the one of the standard system player. Three modes are offered: Off, Automatic and explicit subtitle selection.
      • Provided subtitles are properly described in the stream, the current subtitle selection is saved and restored, as for AVPlayerViewController.
    Source code(tar.gz)
    Source code(zip)
  • 2.5.4(Dec 4, 2018)

    • When a livestream with DVR support takes a long time to load (e.g. on slow networks), the stream was incorrectly starting at the beginning of the DVR window, not at its end. This has been fixed.
    Source code(tar.gz)
    Source code(zip)
  • 2.5.3(Oct 26, 2018)

  • 2.5.2(Sep 28, 2018)

    • Projects depending on SRG Media Player can now be built with Xcode 10 and the iOS 12 SDK. No playback issues will occur anymore.
    • An issue affecting seeks in DVR streams and introduced in version 2.5 has been fixed.
    • Framework dependencies were incorrectly embedded in the SRG Media Player Cocoa Touch framework since version 2.5. This issue, which was leading to iTunes Connect rejection when submitting binaries (duplicate binaries), has been fixed.
    Source code(tar.gz)
    Source code(zip)
Owner
SRG SSR
Swiss Broadcasting Corporation repositories
SRG SSR
Music Player for iOS which looks & feels like classic player

Prodigal Music Player APP looks and feels like a classic device. Bring back the good old player to life. Screenshots Home Page Album Gallery Home Page

bob.sun 40 Nov 11, 2022
Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern and MVVM architecture.

Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern ?? and MVVM architecture ?? . Made with love ❤️ by Sameer Nawaz

Sameer Nawaz 120 Jan 4, 2023
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.

Made by Applikey Solutions Find this project on Dribbble Table of Contents Purpose Features Supported OS & SDK Versions Installation Usage Demo Releas

Applikey Solutions 1.1k Dec 26, 2022
MusicPlayer - Beautiful Music Player app built using SwiftUI to demonstrate Neumorphic design pattern and MVVM architecture

Skailer ?? Beautiful Music Player app built using SwiftUI to demonstrate Neumorp

null 23 Dec 10, 2022
SwiftAudioPlayer - Swift-based audio player with AVAudioEngine as its base

SwiftAudioPlayer Swift-based audio player with AVAudioEngine as its base. Allows for: streaming online audio, playing local file, changing audio speed

null 417 Jan 7, 2023
Player for your DRM-free audiobooks

Please visit our Wiki for our FAQ and guides on how to add new themes and icons to the app. Features Import Using AirDrop from your Mac or iOS device

Tortuga Power 950 Dec 31, 2022
iOS music player app that downloads music from the internet, even YouTube

About YouTag is an iOS music player app that downloads music from the internet, even YouTube, and manages it in a local library. Music videos can also

null 263 Jan 8, 2023
Custom iOS music player view

InteractivePlayerView Custom iOS music player view Screen About InteractivePlayerView is an IBDesignableView (Custom View) which has its own progress,

AhmetKeskin 273 Nov 11, 2022
Multiple Audio Player With Swift

MultipleAudioPlayer I needed to play sequential audio files in a number of places so I made a package. Usage There are 2 inits, one takes filenames fr

chris cieslak 1 Apr 14, 2022
Music Player NBC With Swift

MusicPlayer Xcode command + shift + Y -> Debug 창 띄우기 command + R -> App 실행 command + . -> App 중지 ctrl + option + commadn + return(enter) -> Assistant

davidyoon891122 0 Nov 27, 2021