Code Monkey home page Code Monkey logo

Comments (8)

rviljoen avatar rviljoen commented on June 26, 2024 2

@leandroalonso I think we can close this one now that it is merged. Thanks!

from pocket-casts-ios.

leandroalonso avatar leandroalonso commented on June 26, 2024 1

@rviljoen I agree with your reasoning and ignoring the playbackSpeed.

from pocket-casts-ios.

pocketcasts avatar pocketcasts commented on June 26, 2024

User added:

It also seems to work properly if you create a Shortcut called "Play My Podcasts" and add the "Resume Current Episode" action from Pocket Casts.

from pocket-casts-ios.

reginabally avatar reginabally commented on June 26, 2024

Another report in 5595387-zen, but with the Shortcut app.

UUID for logs: 88705105-78AA-4CB2-B016-B6E760584B3D

App Version: 7.22
Device: iPhone13,4
OS: 16.0

from pocket-casts-ios.

thabotswana avatar thabotswana commented on June 26, 2024

Another report in 5739926-zen

App Version: 7.26
Device: iPhone14,2
OS: 16.1.1

from pocket-casts-ios.

azollafox avatar azollafox commented on June 26, 2024

Once I ask Siri to play PocketCast It will reset the speed of the podcast from 1.6 to 1.
Is there any workaround?

5879165-zen

Version 7.29
Device: iPhone13,3
OS: 16.2

from pocket-casts-ios.

rviljoen avatar rviljoen commented on June 26, 2024

The code for DefaultPlayer already references code to handle a similar problem:

if let rate = self.player?.rate, rate == 1 {
// there's a bug where playback can be resumed from outside our app, and Apple sets the wrong playback rate, fix that here
// the easiest way to repeat this is to play a video at 2x, and press pause once it's in picture in picture mode
let requiredSpeed = PlaybackManager.shared.effects().playbackSpeed
if requiredSpeed != 1 {
self.performSetPlaybackRate()
}
}

Need to investigate if the code is working as intended in DefaultPlayer and if a similar issue may exist in EffectsPlayer, which does not seem to have the same safeguard built in.

from pocket-casts-ios.

rviljoen avatar rviljoen commented on June 26, 2024

I dug a bit more and documenting my findings to date:

  • This happens using both DefaultPlayer and EffectsPlayer

  • When asking Siri to "Resume Pocket Casts" or "Play Pocket Casts" it calls the app via MPRemoteCommandCenter:

    commandCenter.playCommand.addTarget { [weak self] _ -> MPRemoteCommandHandlerStatus in

  • When asking Siri to "Play my podcasts" it does so via Siri intents. This explains the different behaviour between the different Siri commands, as logged in the original report.

    } else if identifier == Constants.SiriActions.resumeId {
    // Shortcuts is removing the mediaItems for the "Play Podcaast" and "Play filter"
    // actions, still handle them by checking for a mediaContainer. The correct
    // mediaContainer is passed to the app untouched
    if thisIntent.mediaContainer?.type == .podcastPlaylist, let uuid = thisIntent.mediaContainer?.identifier {
    responseCode = SiriShortcutsManager.shared.playFilter(uuid: uuid)
    } else if thisIntent.mediaContainer?.type == .podcastShow, let uuid = thisIntent.mediaContainer?.identifier {
    responseCode = SiriShortcutsManager.shared.playPodcast(uuid: uuid)
    } else {
    responseCode = SiriShortcutsManager.shared.resumePlayback()

  • When registering the Siri intent, we do not set a playback speed:

{
    playShuffled = 0;
    mediaContainer = <null>;
    playbackRepeatMode = one;
    mediaItems = (
        <INMediaItem: 0x2826d7e80> {
            artist = <null>;
            topics = <null>;
            privateMediaItemValueData = <null>;
            title = Resuming Current Episode;
            identifier = Resume ID;
            type = 7;
            artwork = <_INBundleImage: 0x2826d7ed0>;
            namedEntities = <null>;
        },
    );
    resumePlayback = 1;
    playbackQueueLocation = unknown;
    playbackSpeed = <null>;
}
  • But when the app is called, iOS does pass along a default playback speed of 1:
{
    playShuffled = 0;
    mediaContainer = <INMediaItem: 0x28266d130> {
        artist = <null>;
        topics = <null>;
        privateMediaItemValueData = <null>;
        title = <null>;
        identifier = library;
        type = 0;
        artwork = <null>;
        namedEntities = <null>;
    };
    playbackRepeatMode = none;
    mediaItems = (
        <INMediaItem: 0x28266d680> {
            artist = <null>;
            topics = <null>;
            privateMediaItemValueData = <null>;
            title = ;
            identifier = Resume ID;
            type = 7;
            artwork = <null>;
            namedEntities = <null>;
        },
    );
    resumePlayback = 1;
    playbackQueueLocation = now;
    playbackSpeed = 1;
}

I assume the speed is sent to cater for commands like "Play my podcasts at double speed" or "Play my podcasts at normal speed". Unfortunately Apple sends 1 as the speed even if the user did not specify any speed. We then set the speed accordingly while ignoring the current speed of the player:

if let spokenSpeed = thisIntent.playbackSpeed, responseCode == .success {
let effects = PlaybackManager.shared.effects()
effects.playbackSpeed = spokenSpeed
PlaybackManager.shared.changeEffects(effects)
PlaybackManager.shared.play()
}

It would be ideal if Apple only passed 1 as the speed if the user explicitly asked for the supported "normal speed". In the interim, we may have to work around this by ignoring the speed setting when 1 is passed along, similar to what DefaultPlayer is doing here for a different, but similar, case:

if let rate = self.player?.rate, rate == 1 {
// there's a bug where playback can be resumed from outside our app, and Apple sets the wrong playback rate, fix that here
// the easiest way to repeat this is to play a video at 2x, and press pause once it's in picture in picture mode
let requiredSpeed = PlaybackManager.shared.effects().playbackSpeed
if requiredSpeed != 1 {
self.performSetPlaybackRate()
}

My sense is that we should ignore the intent playbackSpeed if it is 1. This is not ideal, but the only workaround until Apple changes the API to consider the current playing speed before passing a value to us via the intent.

@emilylaguna @leandroalonso keen to hear your views on this one.

from pocket-casts-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.