Changeset 203982 in webkit


Ignore:
Timestamp:
Aug 1, 2016 12:49:02 PM (8 years ago)
Author:
eric.carlson@apple.com
Message:

[Mac][iOS] Adopt MediaRemote "seek to playback position"
https://bugs.webkit.org/show_bug.cgi?id=160405
<rdar://problem/27547583>

Reviewed by Dean Jackson.

Source/WebCore:

Test: media/remote-control-command-seek.html

  • Modules/webaudio/AudioContext.h: Update for didReceiveRemoteControlCommand argument change.
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::didReceiveRemoteControlCommand): Support SeekToPlaybackPositionCommand.
Drive by fix, support Stop command.
(WebCore::HTMLMediaElement::supportsSeeking): New.

  • html/HTMLMediaElement.h:
  • platform/RemoteCommandListener.h:

(WebCore::RemoteCommandListenerClient::didReceiveRemoteControlCommand): Add command argument.
(WebCore::RemoteCommandListenerClient::supportsSeeking): New.
(WebCore::RemoteCommandListener::updateSupportedCommands): Ditto.
(WebCore::RemoteCommandListener::client): Ditto.

  • platform/audio/PlatformMediaSession.cpp:

(WebCore::PlatformMediaSession::didReceiveRemoteControlCommand): Add command argument.
(WebCore::PlatformMediaSession::supportsSeeking): New, pass through to client.

  • platform/audio/PlatformMediaSession.h:
  • platform/audio/PlatformMediaSessionManager.cpp:

(WebCore::PlatformMediaSessionManager::setCurrentSession): Tell remote command listener to
update supported commands.
(WebCore::PlatformMediaSessionManager::currentSession): Make const.
(WebCore::PlatformMediaSessionManager::didReceiveRemoteControlCommand): Add command argument.
(WebCore::PlatformMediaSessionManager::supportsSeeking): New, pass through to session.

  • platform/audio/PlatformMediaSessionManager.h:
  • platform/ios/RemoteCommandListenerIOS.h:

(WebCore::RemoteCommandListenerIOS::createWeakPtr):

  • platform/ios/RemoteCommandListenerIOS.mm:

(WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS): Support changePlaybackPositionCommand.
(WebCore::RemoteCommandListenerIOS::~RemoteCommandListenerIOS): Remove seekToTime target.
(WebCore::RemoteCommandListenerIOS::updateSupportedCommands): Update changePlaybackPositionCommand.

  • platform/mac/MediaRemoteSoftLink.cpp:
  • platform/mac/MediaRemoteSoftLink.h:
  • platform/mac/RemoteCommandListenerMac.h:
  • platform/mac/RemoteCommandListenerMac.mm:

(WebCore::RemoteCommandListenerMac::updateSupportedCommands): New, split out of constructor.
(WebCore::RemoteCommandListenerMac::RemoteCommandListenerMac): Split setup logic out into
updateSupportedCommands. Support MRMediaRemoteCommandSeekToPlaybackPosition. Don't assert when
receiving an unsupported command, it happens. Return error when a command isn't supported or
fails.

  • testing/Internals.cpp:

(WebCore::Internals::postRemoteControlCommand): Add command argument parameter. Support
seektoplaybackposition.

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

  • media/remote-control-command-seek-expected.txt: Added.
  • media/remote-control-command-seek.html: Added.
Location:
trunk
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203977 r203982  
     12016-08-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [Mac][iOS] Adopt MediaRemote "seek to playback position"
     4        https://bugs.webkit.org/show_bug.cgi?id=160405
     5        <rdar://problem/27547583>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * media/remote-control-command-seek-expected.txt: Added.
     10        * media/remote-control-command-seek.html: Added.
     11
    1122016-08-01  Adrian Perez de Castro  <aperez@igalia.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r203981 r203982  
     12016-08-01  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [Mac][iOS] Adopt MediaRemote "seek to playback position"
     4        https://bugs.webkit.org/show_bug.cgi?id=160405
     5        <rdar://problem/27547583>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Test: media/remote-control-command-seek.html
     10
     11        * Modules/webaudio/AudioContext.h: Update for didReceiveRemoteControlCommand argument change.
     12
     13        * html/HTMLMediaElement.cpp:
     14        (WebCore::HTMLMediaElement::didReceiveRemoteControlCommand): Support SeekToPlaybackPositionCommand.
     15        Drive by fix, support Stop command.
     16        (WebCore::HTMLMediaElement::supportsSeeking): New.
     17        * html/HTMLMediaElement.h:
     18
     19        * platform/RemoteCommandListener.h:
     20        (WebCore::RemoteCommandListenerClient::didReceiveRemoteControlCommand): Add command argument.
     21        (WebCore::RemoteCommandListenerClient::supportsSeeking): New.
     22        (WebCore::RemoteCommandListener::updateSupportedCommands): Ditto.
     23        (WebCore::RemoteCommandListener::client): Ditto.
     24
     25        * platform/audio/PlatformMediaSession.cpp:
     26        (WebCore::PlatformMediaSession::didReceiveRemoteControlCommand): Add command argument.
     27        (WebCore::PlatformMediaSession::supportsSeeking): New, pass through to client.
     28        * platform/audio/PlatformMediaSession.h:
     29
     30        * platform/audio/PlatformMediaSessionManager.cpp:
     31        (WebCore::PlatformMediaSessionManager::setCurrentSession): Tell remote command listener to
     32        update supported commands.
     33        (WebCore::PlatformMediaSessionManager::currentSession): Make const.
     34        (WebCore::PlatformMediaSessionManager::didReceiveRemoteControlCommand): Add command argument.
     35        (WebCore::PlatformMediaSessionManager::supportsSeeking): New, pass through to session.
     36        * platform/audio/PlatformMediaSessionManager.h:
     37
     38        * platform/ios/RemoteCommandListenerIOS.h:
     39        (WebCore::RemoteCommandListenerIOS::createWeakPtr):
     40        * platform/ios/RemoteCommandListenerIOS.mm:
     41        (WebCore::RemoteCommandListenerIOS::RemoteCommandListenerIOS): Support changePlaybackPositionCommand.
     42        (WebCore::RemoteCommandListenerIOS::~RemoteCommandListenerIOS): Remove seekToTime target.
     43        (WebCore::RemoteCommandListenerIOS::updateSupportedCommands): Update changePlaybackPositionCommand.
     44
     45        * platform/mac/MediaRemoteSoftLink.cpp:
     46        * platform/mac/MediaRemoteSoftLink.h:
     47
     48        * platform/mac/RemoteCommandListenerMac.h:
     49        * platform/mac/RemoteCommandListenerMac.mm:
     50        (WebCore::RemoteCommandListenerMac::updateSupportedCommands): New, split out of constructor.
     51        (WebCore::RemoteCommandListenerMac::RemoteCommandListenerMac): Split setup logic out into
     52        updateSupportedCommands. Support MRMediaRemoteCommandSeekToPlaybackPosition. Don't assert when
     53        receiving an unsupported command, it happens. Return error when a command isn't supported or
     54        fails.
     55
     56        * testing/Internals.cpp:
     57        (WebCore::Internals::postRemoteControlCommand): Add command argument parameter. Support
     58        seektoplaybackposition.
     59        * testing/Internals.h:
     60        * testing/Internals.idl:
     61
    1622016-08-01  Anders Carlsson  <andersca@apple.com>
    263
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.h

    r201013 r203982  
    315315    void suspendPlayback() override;
    316316    bool canReceiveRemoteControlCommands() const override { return false; }
    317     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { }
     317    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override { }
     318    bool supportsSeeking() const override { return false; }
    318319    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
    319320
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r203931 r203982  
    68386838}
    68396839
    6840 void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command)
     6840void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
    68416841{
    68426842    LOG(Media, "HTMLMediaElement::didReceiveRemoteControlCommand(%p) - %i", this, static_cast<int>(command));
     
    68476847        play();
    68486848        break;
     6849    case PlatformMediaSession::StopCommand:
    68496850    case PlatformMediaSession::PauseCommand:
    68506851        pause();
     
    68636864        endScanning();
    68646865        break;
     6866    case PlatformMediaSession::SeekToPlaybackPositionCommand:
     6867        ASSERT(argument);
     6868        if (argument)
     6869            fastSeek(argument->asDouble);
     6870        break;
    68656871    default:
    68666872        { } // Do nothing
    68676873    }
     6874}
     6875
     6876bool HTMLMediaElement::supportsSeeking() const
     6877{
     6878    return !isLiveStream();
    68686879}
    68696880
  • trunk/Source/WebCore/html/HTMLMediaElement.h

    r203066 r203982  
    617617
    618618    bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) override;
    619     void mediaPlayerHandlePlaybackCommand(PlatformMediaSession::RemoteControlCommandType command) override { didReceiveRemoteControlCommand(command); }
     619    void mediaPlayerHandlePlaybackCommand(PlatformMediaSession::RemoteControlCommandType command) override { didReceiveRemoteControlCommand(command, nullptr); }
    620620    String mediaPlayerSourceApplicationIdentifier() const override;
    621621    Vector<String> mediaPlayerPreferredAudioCharacteristics() const override;
     
    758758    double mediaSessionCurrentTime() const override { return currentTime(); }
    759759    bool canReceiveRemoteControlCommands() const override { return true; }
    760     void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
     760    void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
     761    bool supportsSeeking() const override;
    761762    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
    762763    bool shouldOverrideBackgroundLoadingRestriction() const override;
  • trunk/Source/WebCore/platform/RemoteCommandListener.h

    r185006 r203982  
    3535public:
    3636    virtual ~RemoteCommandListenerClient() { }
    37     virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) = 0;
     37    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) = 0;
     38    virtual bool supportsSeeking() const = 0;
    3839};
    3940
     
    4445    virtual ~RemoteCommandListener() { }
    4546
     47    virtual void updateSupportedCommands() { }
     48
     49    RemoteCommandListenerClient& client() const { return m_client; }
     50
    4651protected:
    4752    RemoteCommandListenerClient& m_client;
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r203388 r203982  
    243243}
    244244
    245 void PlatformMediaSession::didReceiveRemoteControlCommand(RemoteControlCommandType command)
    246 {
    247     m_client.didReceiveRemoteControlCommand(command);
     245void PlatformMediaSession::didReceiveRemoteControlCommand(RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
     246{
     247    m_client.didReceiveRemoteControlCommand(command, argument);
     248}
     249
     250bool PlatformMediaSession::supportsSeeking() const
     251{
     252    return m_client.supportsSeeking();
    248253}
    249254
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.h

    r202425 r203982  
    115115#endif
    116116
     117    typedef union {
     118        double asDouble;
     119    } RemoteCommandArgument;
     120
    117121    enum RemoteControlCommandType {
    118122        NoCommand,
     
    125129        BeginSeekingForwardCommand,
    126130        EndSeekingForwardCommand,
     131        SeekToPlaybackPositionCommand,
    127132    };
    128133    bool canReceiveRemoteControlCommands() const;
    129     void didReceiveRemoteControlCommand(RemoteControlCommandType);
     134    void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument* argument = nullptr);
     135    bool supportsSeeking() const;
    130136
    131137    enum DisplayType {
     
    203209   
    204210    virtual bool canReceiveRemoteControlCommands() const = 0;
    205     virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) = 0;
     211    virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) = 0;
     212    virtual bool supportsSeeking() const = 0;
    206213
    207214    virtual void setShouldBufferData(bool) { }
  • trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp

    r202642 r203982  
    267267    m_sessions.remove(index);
    268268    m_sessions.insert(0, &session);
     269    if (m_remoteCommandListener)
     270        m_remoteCommandListener->updateSupportedCommands();
    269271   
    270272    LOG(Media, "PlatformMediaSessionManager::setCurrentSession - session moved from index %zu to 0", index);
    271273}
    272274   
    273 PlatformMediaSession* PlatformMediaSessionManager::currentSession()
     275PlatformMediaSession* PlatformMediaSessionManager::currentSession() const
    274276{
    275277    if (!m_sessions.size())
     
    345347#endif
    346348
    347 void PlatformMediaSessionManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command)
     349void PlatformMediaSessionManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
    348350{
    349351    PlatformMediaSession* activeSession = currentSession();
    350352    if (!activeSession || !activeSession->canReceiveRemoteControlCommands())
    351353        return;
    352     activeSession->didReceiveRemoteControlCommand(command);
     354    activeSession->didReceiveRemoteControlCommand(command, argument);
     355}
     356
     357bool PlatformMediaSessionManager::supportsSeeking() const
     358{
     359    PlatformMediaSession* activeSession = currentSession();
     360    if (!activeSession)
     361        return false;
     362    return activeSession->supportsSeeking();
    353363}
    354364
  • trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h

    r202425 r203982  
    9191
    9292    void setCurrentSession(PlatformMediaSession&);
    93     PlatformMediaSession* currentSession();
     93    PlatformMediaSession* currentSession() const;
    9494
    9595    PlatformMediaSession* currentSessionMatching(std::function<bool(const PlatformMediaSession&)>);
     
    113113
    114114    // RemoteCommandListenerClient
    115     WEBCORE_EXPORT void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
     115    WEBCORE_EXPORT void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
     116    WEBCORE_EXPORT bool supportsSeeking() const override;
    116117
    117118    // AudioHardwareListenerClient
  • trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h

    r166101 r203982  
    4747protected:
    4848    WeakPtr<RemoteCommandListenerIOS> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
    49    
     49    void updateSupportedCommands() override;
     50
    5051    WeakPtrFactory<RemoteCommandListenerIOS> m_weakPtrFactory;
    5152    RetainPtr<id> m_playTarget;
     
    5455    RetainPtr<id> m_seekForwardTarget;
    5556    RetainPtr<id> m_seekBackwardTarget;
     57    RetainPtr<id> m_seekToTimeTarget;
    5658};
    5759
  • trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm

    r185006 r203982  
    3737SOFT_LINK_CLASS(MediaPlayer, MPRemoteCommandCenter)
    3838SOFT_LINK_CLASS(MediaPlayer, MPSeekCommandEvent)
     39#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100
     40SOFT_LINK_CLASS(MediaPlayer, MPChangePlaybackPositionCommandEvent)
     41#endif
    3942
    4043namespace WebCore {
     
    5659            if (!weakThis)
    5760                return;
    58             weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PauseCommand);
     61            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PauseCommand, nullptr);
    5962        });
    6063
     
    6669            if (!weakThis)
    6770                return;
    68             weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PlayCommand);
     71            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PlayCommand, nullptr);
    6972        });
    7073
     
    7679            if (!weakThis)
    7780                return;
    78             weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand);
     81            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand, nullptr);
    7982        });
    8083
     
    9194            if (!weakThis)
    9295                return;
    93             weakThis->m_client.didReceiveRemoteControlCommand(command);
     96            weakThis->m_client.didReceiveRemoteControlCommand(command, nullptr);
    9497        });
    9598
     
    106109            if (!weakThis)
    107110                return;
    108             weakThis->m_client.didReceiveRemoteControlCommand(command);
     111            weakThis->m_client.didReceiveRemoteControlCommand(command, nullptr);
    109112        });
    110113
    111114        return MPRemoteCommandHandlerStatusSuccess;
    112115    }];
     116
     117#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100
     118    m_seekToTimeTarget = [[center changePlaybackPositionCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) {
     119        ASSERT([event isKindOfClass:getMPChangePlaybackPositionCommandEventClass()]);
     120
     121        if (!client.supportsSeeking())
     122            return MPRemoteCommandHandlerStatusCommandFailed;
     123
     124        MPChangePlaybackPositionCommandEvent* seekEvent = static_cast<MPChangePlaybackPositionCommandEvent *>(event);
     125        PlatformMediaSession::RemoteCommandArgument argument { [seekEvent positionTime] };
     126
     127        callOnMainThread([weakThis, argument] {
     128            if (!weakThis)
     129                return;
     130            weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand, &argument);
     131        });
     132
     133        return MPRemoteCommandHandlerStatusSuccess;
     134    }];
     135#endif
    113136}
    114137
     
    121144    [[center seekForwardCommand] removeTarget:m_seekForwardTarget.get()];
    122145    [[center seekBackwardCommand] removeTarget:m_seekBackwardTarget.get()];
     146#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100
     147    [[center changePlaybackPositionCommand] removeTarget:m_seekToTimeTarget.get()];
     148#endif
     149}
     150
     151void RemoteCommandListenerIOS::updateSupportedCommands()
     152{
     153#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100
     154    [[[getMPRemoteCommandCenterClass() sharedCommandCenter] changePlaybackPositionCommand] setEnabled:!!client().supportsSeeking()];
     155#endif
    123156}
    124157
  • trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp

    r202642 r203982  
    4747SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoElapsedTime, CFStringRef);
    4848SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoPlaybackRate, CFStringRef);
     49SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteOptionPlaybackPosition, CFStringRef);
    4950
    5051#endif // USE(MEDIAREMOTE)
  • trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h

    r202642 r203982  
    6262SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoPlaybackRate, CFStringRef);
    6363#define kMRMediaRemoteNowPlayingInfoPlaybackRate get_MediaRemote_kMRMediaRemoteNowPlayingInfoPlaybackRate()
     64SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteOptionPlaybackPosition, CFStringRef);
     65#define kMRMediaRemoteOptionPlaybackPosition get_MediaRemote_kMRMediaRemoteOptionPlaybackPosition()
    6466
    6567#endif // USE(MEDIAREMOTE)
  • trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h

    r202642 r203982  
    4343    WeakPtr<RemoteCommandListenerMac> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
    4444
     45    void updateSupportedCommands() override;
     46
    4547    WeakPtrFactory<RemoteCommandListenerMac> m_weakPtrFactory { this };
    4648    void* m_commandHandler { nullptr };
  • trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm

    r202642 r203982  
    4141}
    4242
    43 RemoteCommandListenerMac::RemoteCommandListenerMac(RemoteCommandListenerClient& client)
    44     : RemoteCommandListener(client)
     43void RemoteCommandListenerMac::updateSupportedCommands()
    4544{
    4645#if USE(MEDIAREMOTE)
     
    6766    }
    6867
     68    auto seekCommandInfo = adoptCF(MRMediaRemoteCommandInfoCreate(kCFAllocatorDefault));
     69    MRMediaRemoteCommandInfoSetCommand(seekCommandInfo.get(), MRMediaRemoteCommandSeekToPlaybackPosition);
     70    MRMediaRemoteCommandInfoSetEnabled(seekCommandInfo.get(), client().supportsSeeking());
     71    CFArrayAppendValue(commandInfoArray.get(), seekCommandInfo.get());
     72
    6973    MRMediaRemoteSetSupportedCommands(commandInfoArray.get(), MRMediaRemoteGetLocalOrigin(), nullptr, nullptr);
     74#endif // USE(MEDIAREMOTE)
     75}
     76
     77RemoteCommandListenerMac::RemoteCommandListenerMac(RemoteCommandListenerClient& client)
     78    : RemoteCommandListener(client)
     79{
     80#if USE(MEDIAREMOTE)
     81    if (!isMediaRemoteFrameworkAvailable())
     82        return;
     83
     84    updateSupportedCommands();
    7085
    7186    auto weakThis = createWeakPtr();
    7287    m_commandHandler = MRMediaRemoteAddAsyncCommandHandlerBlock(^(MRMediaRemoteCommand command, CFDictionaryRef options, void(^completion)(CFArrayRef)) {
    73         UNUSED_PARAM(options);
     88
     89        LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - received command %u", command);
    7490
    7591        PlatformMediaSession::RemoteControlCommandType platformCommand { PlatformMediaSession::NoCommand };
     92        PlatformMediaSession::RemoteCommandArgument argument { 0 };
     93        MRMediaRemoteCommandHandlerStatus status = MRMediaRemoteCommandHandlerStatusSuccess;
    7694
    7795        switch (command) {
     
    8199        case MRMediaRemoteCommandPause:
    82100            platformCommand = PlatformMediaSession::PauseCommand;
     101            break;
     102        case MRMediaRemoteCommandStop:
     103            platformCommand = PlatformMediaSession::StopCommand;
    83104            break;
    84105        case MRMediaRemoteCommandTogglePlayPause:
     
    97118            platformCommand = PlatformMediaSession::EndSeekingBackwardCommand;
    98119            break;
     120        case MRMediaRemoteCommandSeekToPlaybackPosition: {
     121            if (!client.supportsSeeking()) {
     122                status = MRMediaRemoteCommandHandlerStatusCommandFailed;
     123                break;
     124            }
     125
     126            CFNumberRef positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionPlaybackPosition));
     127            if (!positionRef) {
     128                status = MRMediaRemoteCommandHandlerStatusCommandFailed;
     129                break;
     130            }
     131
     132            CFNumberGetValue(positionRef, kCFNumberDoubleType, &argument.asDouble);
     133            platformCommand = PlatformMediaSession::SeekToPlaybackPositionCommand;
     134            break;
     135        }
    99136        default:
    100             ASSERT_NOT_REACHED();
     137            LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - command %u not supported!", command);
     138            status = MRMediaRemoteCommandHandlerStatusCommandFailed;
     139            return;
    101140        };
    102141
    103142        if (!weakThis)
    104143            return;
    105         weakThis->m_client.didReceiveRemoteControlCommand(platformCommand);
    106         completion(static_cast<CFArrayRef>(@[@0]));
     144        weakThis->m_client.didReceiveRemoteControlCommand(platformCommand, &argument);
     145        completion(static_cast<CFArrayRef>(@[@(status)]));
    107146    });
    108147#endif // USE(MEDIAREMOTE)
  • trunk/Source/WebCore/testing/Internals.cpp

    r203644 r203982  
    28812881}
    28822882
    2883 void Internals::postRemoteControlCommand(const String& commandString, ExceptionCode& ec)
     2883void Internals::postRemoteControlCommand(const String& commandString, float argument, ExceptionCode& ec)
    28842884{
    28852885    PlatformMediaSession::RemoteControlCommandType command;
    2886    
     2886    PlatformMediaSession::RemoteCommandArgument parameter { argument };
     2887
    28872888    if (equalLettersIgnoringASCIICase(commandString, "play"))
    28882889        command = PlatformMediaSession::PlayCommand;
     
    29012902    else if (equalLettersIgnoringASCIICase(commandString, "endseekingforward"))
    29022903        command = PlatformMediaSession::EndSeekingForwardCommand;
     2904    else if (equalLettersIgnoringASCIICase(commandString, "seektoplaybackposition"))
     2905        command = PlatformMediaSession::SeekToPlaybackPositionCommand;
    29032906    else {
    29042907        ec = INVALID_ACCESS_ERR;
     
    29062909    }
    29072910   
    2908     PlatformMediaSessionManager::sharedManager().didReceiveRemoteControlCommand(command);
     2911    PlatformMediaSessionManager::sharedManager().didReceiveRemoteControlCommand(command, &parameter);
    29092912}
    29102913
  • trunk/Source/WebCore/testing/Internals.h

    r203623 r203982  
    412412    void setMediaSessionRestrictions(const String& mediaType, const String& restrictions, ExceptionCode&);
    413413    void setMediaElementRestrictions(HTMLMediaElement&, const String& restrictions);
    414     void postRemoteControlCommand(const String&, ExceptionCode&);
     414    void postRemoteControlCommand(const String&, float argument, ExceptionCode&);
    415415    bool elementIsBlockingDisplaySleep(HTMLMediaElement&) const;
    416416#endif
  • trunk/Source/WebCore/testing/Internals.idl

    r203623 r203982  
    407407    [Conditional=VIDEO] void setMediaElementRestrictions(HTMLMediaElement element, DOMString restrictions);
    408408    [Conditional=WEB_AUDIO] void setAudioContextRestrictions(AudioContext context, DOMString restrictions);
    409     [Conditional=VIDEO, RaisesException] void postRemoteControlCommand(DOMString command);
     409    [Conditional=VIDEO, RaisesException] void postRemoteControlCommand(DOMString command, optional unrestricted float argument = 0);
    410410    [Conditional=WIRELESS_PLAYBACK_TARGET] void setMockMediaPlaybackTargetPickerEnabled(boolean enabled);
    411411    [Conditional=WIRELESS_PLAYBACK_TARGET, RaisesException] void setMockMediaPlaybackTargetPickerState(DOMString deviceName, DOMString deviceState);
Note: See TracChangeset for help on using the changeset viewer.