Skip to content

Releases: SvenTiigi/YouTubePlayerKit

Version 2.0.5

30 Nov 11:01

Choose a tag to compare

What's Changed

  • Added YouTubePlayer.Error.missingAPIClientIdentification case
  • Updated the default origin url to use the bundle identifier for the host

Full Changelog: 2.0.4...2.0.5

Version 2.0.4

15 Oct 17:53

Choose a tag to compare

What's Changed

  • Fix memory leak on frame observer by @Katsz in #141

New Contributors

Full Changelog: 2.0.3...2.0.4

Version 2.0.3

06 Oct 17:09
8525623

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 2.0.2...2.0.3

Version 2.0.2

10 Sep 07:32

Choose a tag to compare

What's Changed

  • Fixed a bug that caused a compile error during the archiving process using >= Xcode 26 (#127)

Full Changelog: 2.0.1...2.0.2

Version 2.0.1

18 Jul 16:05

Choose a tag to compare

What's Changed

  • Update README.md by @emin-grbo in #126
  • Allow redirect to YouTube app when tapping the YouTube icon (#128)
  • Changed default value for useNonPersistentWebsiteDataStore to false which allows the system to correctly set the now playing info

New Contributors

Full Changelog: 2.0.0...2.0.1

Version 2.0.0

03 Feb 21:33

Choose a tag to compare

What's Changed

Important

This release contains several breaking changes when coming from version 1.9.0 or earlier.
Please refer to the updated README and documentation for the latest APIs of the YouTubePlayerKit.
Full Changelog: 1.9.0...2.0.0

  • Support for Swift 6 strict concurrency checks and data race safety.
  • Improved code documentation and provided additional insights into the specific behaviors of several APIs and properties.
  • Improved performance and stability.
  • Bumped minimum deployment target for iOS from 13 to 15 and for macOS from 10.15 to 12
  • First class async/await function API (removal of completion closure based APIs).
  • Added several new APIs such as observing the fullscreen and volume state as well as changing the caption font size.
  • Improved URL parsing of the YouTubePlayer.Source for the most common and well known YouTube URL formats.
  • Added a new enumeration case .videos(ids:) to the YouTubePlayer.Source allowing to play individual video identifiers as a playlist.
  • Added advanced APIs to observe the incoming stream of YouTubePlayer.Event as well as to run custom JavaScript code and supply custom HTML code.
  • Added logging which can enabled when initializing an instance of YouTubePlayer to gain more insights of the underlying JavaScript communication and stream of events.
  • Improved example application.
  • Migrated tests from XCTest to Swift Testing.

Migration Guide

When coming from version 1.9.0 or earlier there are two main topics to consider.

YouTubePlayer Initialization

In Version 2.0.0 the designated initializer of a YouTubePlayer takes four parameters: a source, parameters, a configuration and a boolean whether logging should be enabled. Previously the player was initialized with just two arguments a source and a configuration.

let youTubePlayer = YouTubePlayer(
    // Possible values: .video, .videos, .playlist, .channel
    source: .video(id: "psL_5RIBqnY"),
    // The parameters of the player
    parameters: .init(
        autoPlay: true,
        showControls: true,
        loopEnabled: true,
        startTime: .init(value: 5, unit: .minutes),
        // ...
    ),
    // The configuration of the underlying web view
    configuration: .init(
        fullscreenMode: .system,
        allowsInlineMediaPlayback: true,
        customUserAgent: "MyCustomUserAgent",
        // ...
    ),
    isLoggingEnabled: true
)

To differentiate between parameters and configuration, understand that parameters control the behavior and style of the YouTube player, while the configuration is linked to the underlying web view.
You cannot modify the configuration after instantiation; however, it is possible to update the parameters, as shown below:

youTubePlayer.parameters.showControls = false

Warning

Updating the YouTubePlayer.Parameters during runtime will cause the player to reload.

Async/Await APIs

In version 1.9.0 and earlier, YouTubePlayerKit offered both a completion closure-based API and an async API. Starting with version 2.0.0, only the async variant will be supported as the primary API.

- youTubePlayer.isMuted { result in /* ... */ }
+ let isMuted = try await youTubePlayer.isMuted()

In case of an error, most of the functions are typed to throw a YouTubePlayer.APIError.
This allows you to easily examine the reason for the error, any underlying error, and the executed JavaScript along with its response.

do {
    try await youTubePlayer.setCaptions(fontSize: .small)
} catch {
    print(
        "Failed to set captions font size",
        error.reason,
        error.underlyingError,
        error.javaScript,
        error.javaScriptResponse
    )
}

Version 1.9.0

11 Aug 07:19

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 1.8.0...1.9.0

Version 1.8.0

11 Apr 18:50

Choose a tag to compare

What's Changed

  • Added set(startTime:) function to set the start time of a video
  • Added fastForward and rewind functions
  • Refactored duration & time return types from Double to Measurement
  • Add additional convenience method for creating a YouTubePlayer.Source from a URL object by @armadsen in #87

New Contributors

Full Changelog: 1.7.0...1.8.0

Version 1.7.0

01 Feb 19:37

Choose a tag to compare

What's Changed

  • Added support for visionOS

Full Changelog: 1.6.0...1.7.0

Version 1.6.0

10 Jan 21:54

Choose a tag to compare

What's Changed

  • Added additional PlaybackQuality value that occurs for some videos by @shadone in #78
  • Fixed a bug that could potentially cause a runtime crash due to a race condition. (#79)
  • Improved YouTubePlayer API

New Contributors

Full Changelog: 1.5.4...1.6.0