Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

extension Episode {
/// MIME type advertised for HLS streams inside a feed's `alternate_enclosures`.
static let hlsEnclosureType = "application/x-mpegURL"
public static let hlsEnclosureType = "application/x-mpegURL"

/// Extracts the HLS stream URL from a feed episode's `alternate_enclosures` array, if one is present.
///
Expand Down
13 changes: 10 additions & 3 deletions podcasts/Google Cast/GoogleCastManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,12 @@ class GoogleCastManager: NSObject, GCKRemoteMediaClientListener, GCKSessionManag
episodeToPlayOnConnect = episode
bufferingInitialPartOfEpisode = true

// metadata about the episode to display on the Google Cast
let episodeMetadata = GCKMediaMetadata(metadataType: episode.videoPodcast() ? .movie : .musicTrack)
// metadata about the episode to display on the Google Cast.
// HLS streams can carry video that isn't reflected in the episode's file type, and the phone
// only knows for sure once it's decoded locally. To keep things simple we assume any HLS
// stream is video so the receiver renders it rather than presenting audio-only.
let isHLS = EpisodeManager.isStreamingHLS(episode)
let episodeMetadata = GCKMediaMetadata(metadataType: (episode.videoPodcast() || isHLS) ? .movie : .musicTrack)

if let episode = episode as? Episode, let uuid = episode.parentPodcast()?.uuid {
let episodeImage = GCKImage(url: ServerHelper.imageUrl(podcastUuid: uuid, size: 680), width: 680, height: 680)
Expand All @@ -213,7 +217,10 @@ class GoogleCastManager: NSObject, GCKRemoteMediaClientListener, GCKSessionManag
// custom data that things like the iOS and Android app know to look for
let episodeInfo = [episodeUuidKey: episode.uuid]
let downloadUrl = EpisodeManager.urlForEpisode(episode, streamingOnly: true)
let fileType = episode.fileType ?? ""
// When streaming HLS, the content URL is an .m3u8 manifest, not the progressive file.
// The receiver needs the HLS content type to load it — the episode's file type describes
// the progressive enclosure and would make the receiver try to play the manifest directly.
let fileType = isHLS ? Episode.hlsEnclosureType : (episode.fileType ?? "")
let mediaBuilder = GCKMediaInformationBuilder()
mediaBuilder.contentURL = downloadUrl
mediaBuilder.streamType = .buffered
Expand Down