An advanced media player library, simple and reliable

Related tags

Video 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...
iOS video player for trailer. You can customize layout for the control panel. Support PiP and DRM.

iOS video player for trailer. You can customize layout for the control panel. Support PiP and DRM.

YouTube video player for iOS, tvOS and macOS
YouTube video player for iOS, tvOS and macOS

About XCDYouTubeKit is a YouTube video player for iOS, tvOS and macOS. Are you enjoying XCDYouTubeKit? You can say thank you with a tweet. I am also a

Support customization of any player SDK and control layer
Support customization of any player SDK and control layer

Support customization of any player SDK and control layer

YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app
YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI for easily create a Youtube app

YoutubeKit YoutubeKit is a video player that fully supports Youtube IFrame API and YoutubeDataAPI to easily create Youtube applications. Important Ref

Versatile Video Player implementation for iOS, macOS, and tvOS
Versatile Video Player implementation for iOS, macOS, and tvOS

News 🎉 - Since 2.1.3 VersaPlayer now supports iOS, macOS, and tvOS Example Installation Usage Basic Usage Adding Controls Advanced Usage Encrypted Co

Audio player demo based on Swift and SwiftUI, which can play local or network audio.
Audio player demo based on Swift and SwiftUI, which can play local or network audio.

SwiftAudioDemo Audio player demo based on Swift and SwiftUI, which can play local or network audio. In this demo, I have made a radio player to play n

WatchTube: a standalone WatchOS youtube player utilizing Download API for search data and video streaming
WatchTube: a standalone WatchOS youtube player utilizing Download API for search data and video streaming

WatchTube is a standalone WatchOS youtube player utilizing Download API for sear

BMPlayer - A video player for iOS, based on AVPlayer, support the horizontal, vertical screen
BMPlayer - A video player for iOS, based on AVPlayer, support the horizontal, vertical screen

A video player for iOS, based on AVPlayer, support the horizontal, vertical screen. support adjust volume, brightness and seek by slide, support subtitles.

Overlay alpha channel video animation player view using Metal.
Overlay alpha channel video animation player view using Metal.

Overlay alpha channel video animation player view using Metal. Example To run the example project, clone the repo, and run pod install from the Exampl

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
MobilePlayer - A powerful and completely customizable media player for iOS

MobilePlayer A powerful and completely customizable media player for iOS. Table of Contents Features Installation Usage Customization Skinning Showing

Sahin Boydas 3k Jan 2, 2023
A powerful and completely customizable media player for iOS

MobilePlayer A powerful and completely customizable media player for iOS. Table of Contents Features Installation Usage Customization Skinning Showing

Sahin Boydas 3k Jan 2, 2023
VLC media player

VLC media player VLC is a libre and open source media player and multimedia engine, focused on playing everything, and running everywhere. VLC can pla

VideoLAN 10.1k Dec 24, 2022
Musical Player - A Simple Musical Player For iOS

Musical_Player The app is a musical player. It was written as an task for a mobi

null 1 Nov 26, 2022
NextLevelSessionExporter is an export and transcode media library for iOS written in Swift.

NextLevelSessionExporter ?? NextLevelSessionExporter is an export and transcode media library for iOS written in Swift. The library provides customiza

NextLevel 233 Nov 27, 2022
VGPlayer - 📺 A simple iOS video player by Vein.

Swift developed based on AVPlayer iOS player,support horizontal gestures Fast forward, pause, vertical gestures Support brightness and volume adjustment, support full screen, adaptive screen rotation direction.

Wen Rong 399 Dec 23, 2022
MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

MMPlayerView Demo-Swift List / Shrink / Transition / Landscape MMPlayerLayer ex. use when change player view frequently like tableView / collectionVie

Millman Yang 724 Nov 24, 2022
Yattee: video player for Invidious and Piped built for iOS 15, tvOS 15 and macOS Monterey

Video player with support for Invidious and Piped instances built for iOS 15, tvOS 15 and macOS Monterey.

Yattee 1k Dec 27, 2022
Yattee: video player for Invidious and Piped built for iOS, tvOS and macOS

Video player for Invidious and Piped instances built for iOS, tvOS and macOS. Features Native user interface built with SwiftUI Multiple instances and

Yattee 1.1k Jan 8, 2023
📽 A video player for SwiftUI, support for caching, preload and custom control view.

Features QuickStart Advances Installation Requirements License Demo Clone or download the project. In the terminal, run swift package resolve. Open Vi

Gesen 437 Jan 5, 2023