diff --git a/sphinx.xcodeproj/project.pbxproj b/sphinx.xcodeproj/project.pbxproj index d61b50962..e274e28d7 100644 --- a/sphinx.xcodeproj/project.pbxproj +++ b/sphinx.xcodeproj/project.pbxproj @@ -5458,7 +5458,7 @@ "\"UIKit\"", "-ObjC", ); - PRODUCT_BUNDLE_IDENTIFIER = com.gl.sphinx; + PRODUCT_BUNDLE_IDENTIFIER = "com.gl.sphinx"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/sphinx/Crypter/Sphinxrs-Bridging-Header.h"; SWIFT_VERSION = 4.2; @@ -5551,7 +5551,7 @@ "\"UIKit\"", "-ObjC", ); - PRODUCT_BUNDLE_IDENTIFIER = com.gl.sphinx; + PRODUCT_BUNDLE_IDENTIFIER = "com.gl.sphinx"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/sphinx/Crypter/Sphinxrs-Bridging-Header.h"; SWIFT_VERSION = 4.2; diff --git a/sphinx/Core Data/Wrappers/Podcast/Podcast Episode/PodcastEpisode+Properties.swift b/sphinx/Core Data/Wrappers/Podcast/Podcast Episode/PodcastEpisode+Properties.swift index a8ce2a0fc..b0186f2d8 100644 --- a/sphinx/Core Data/Wrappers/Podcast/Podcast Episode/PodcastEpisode+Properties.swift +++ b/sphinx/Core Data/Wrappers/Podcast/Podcast Episode/PodcastEpisode+Properties.swift @@ -87,6 +87,18 @@ extension PodcastEpisode { return podcastEpisode } + func isMostLikelyMusic()->Bool{ + if let valid_feed = self.feed, + let valid_pd = valid_feed.podcastDescription, + valid_pd.contains("music"){ + return true + } + else if(self.duration ?? 0 < (60 * 10)){ + return true + } + return false + } + var isMusicClip: Bool { return type == RecommendationsHelper.PODCAST_TYPE || type == RecommendationsHelper.TWITTER_TYPE } diff --git a/sphinx/Scenes/WebAppsAndPodcasts/Helper/PodcastPlayerHelper.swift b/sphinx/Scenes/WebAppsAndPodcasts/Helper/PodcastPlayerHelper.swift index 03f186fc3..53e8ea0fc 100644 --- a/sphinx/Scenes/WebAppsAndPodcasts/Helper/PodcastPlayerHelper.swift +++ b/sphinx/Scenes/WebAppsAndPodcasts/Helper/PodcastPlayerHelper.swift @@ -330,7 +330,8 @@ class PodcastPlayerHelper { guard let player = player, let item = player.currentItem else { return } - + print(player.currentTime().value) + print(player.currentTime().timescale) let duration = Int(Double(item.asset.duration.value) / Double(item.asset.duration.timescale)) let currentTime = Int(round(Double(player.currentTime().value) / Double(player.currentTime().timescale))) @@ -559,6 +560,8 @@ class PodcastPlayerHelper { ) { var newTime = podcast.currentTime + Int(seconds) newTime = newTime > 0 ? newTime : 0 + let duration = podcast.getCurrentEpisode()?.duration ?? 0 + newTime = newTime > duration ? duration : newTime if podcast.feedID != self.podcast?.feedID { podcast.currentTime = newTime diff --git a/sphinx/Scenes/WebAppsAndPodcasts/NewPodcastPlayerViewController.swift b/sphinx/Scenes/WebAppsAndPodcasts/NewPodcastPlayerViewController.swift index c643a8059..b0dbc53f0 100644 --- a/sphinx/Scenes/WebAppsAndPodcasts/NewPodcastPlayerViewController.swift +++ b/sphinx/Scenes/WebAppsAndPodcasts/NewPodcastPlayerViewController.swift @@ -166,6 +166,13 @@ extension NewPodcastPlayerViewController : PodcastEpisodesDSDelegate { } extension NewPodcastPlayerViewController : PodcastPlayerViewDelegate { + func getCurrentEpisodeIndex() -> Int? { + return self.tableDataSource.podcast.getCurrentEpisodeIndex() + } + + func getTotalEpisodeCount() -> Int? { + return tableView.numberOfRows(inSection: 0) + } func didTapSubscriptionToggleButton() { if let objectID = podcast.objectID { diff --git a/sphinx/Scenes/WebAppsAndPodcasts/Views/PodcastPlayerView.swift b/sphinx/Scenes/WebAppsAndPodcasts/Views/PodcastPlayerView.swift index 5266ec9b0..1373c600c 100644 --- a/sphinx/Scenes/WebAppsAndPodcasts/Views/PodcastPlayerView.swift +++ b/sphinx/Scenes/WebAppsAndPodcasts/Views/PodcastPlayerView.swift @@ -15,6 +15,8 @@ protocol PodcastPlayerViewDelegate: AnyObject { func shouldShareClip(comment: PodcastComment) func shouldSyncPodcast() func shouldShowSpeedPicker() + func getCurrentEpisodeIndex()->Int? + func getTotalEpisodeCount()->Int? } class PodcastPlayerView: UIView { @@ -60,8 +62,9 @@ class PodcastPlayerView: UIView { let feedBoostHelper = FeedBoostHelper() var playerHelper: PodcastPlayerHelper = PodcastPlayerHelper.sharedInstance - + var startingIndex : Int = 0 var podcast: PodcastFeed! = nil + var isHittingNextTrack = false var chat: Chat? { get { @@ -81,7 +84,8 @@ class PodcastPlayerView: UIView { podcast: PodcastFeed, delegate: PodcastPlayerViewDelegate, boostDelegate: CustomBoostDelegate, - fromDashboard: Bool + fromDashboard: Bool, + startingIndex:Int = 0 ) { let windowWidth = WindowsManager.getWindowWidth() let frame = CGRect(x: 0, y: 0, width: windowWidth, height: windowWidth + PodcastPlayerView.kPlayerHeight) @@ -103,6 +107,26 @@ class PodcastPlayerView: UIView { setupView() setupActions(fromDashboard) + + DispatchQueue.main.asyncAfter(deadline: .now() + 2.0, execute: { + //self.playNextMusicTrack() + }) + } + + func playNextMusicTrack(){ + if let valid_episode = podcast.getCurrentEpisode(), + (valid_episode.isMostLikelyMusic()), + let valid_delegate = delegate, + let valid_index = valid_delegate.getCurrentEpisodeIndex(), + let valid_total = valid_delegate.getTotalEpisodeCount(), + valid_total > valid_index{ + DispatchQueue.main.async { + if(self.isHittingNextTrack == false){ + self.isHittingNextTrack = true + self.didTapEpisodeAt(index: valid_index + 1) + } + } + } } private var subscriptionToggleButtonTitle: String { @@ -167,7 +191,6 @@ class PodcastPlayerView: UIView { func loadTime() { let episode = podcast.getCurrentEpisode() - if let duration = episode?.duration { let _ = setProgress( duration: duration, @@ -263,6 +286,13 @@ class PodcastPlayerView: UIView { progressLineWidth.constant = progressWidth progressLine.layoutIfNeeded() + if(progress >= 0.995){ + playNextMusicTrack() + } + else if(progress >= 0.01){ + self.isHittingNextTrack = false + } + return didChangeCurrentTime }