/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
# include <functional> # include <Windows.Media.h> # include <wrl.h>
# include "mozilla/dom/FetchImageHelper.h" # include "mozilla/dom/MediaController.h" # include "mozilla/dom/MediaControlKeySource.h" # include "mozilla/UniquePtr.h"
using ISMTC = ABI::Windows::Media::ISystemMediaTransportControls; using SMTCProperty = ABI::Windows::Media::SystemMediaTransportControlsProperty; using ISMTCDisplayUpdater =
ABI::Windows::Media::ISystemMediaTransportControlsDisplayUpdater;
using ABI::Windows::Foundation::IAsyncOperation; using ABI::Windows::Storage::Streams::IDataWriter; using ABI::Windows::Storage::Streams::IRandomAccessStream; using ABI::Windows::Storage::Streams::IRandomAccessStreamReference; using Microsoft::WRL::ComPtr;
class WindowsSMTCProvider final : public mozilla::dom::MediaControlKeySource {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WindowsSMTCProvider, override)
// Sets the Metadata for the currently playing media and sets the playback // type to "MUSIC" bool SetMusicMetadata(const nsString& aArtist, const nsString& aTitle);
// Sets one of the artwork to the SMTC interface asynchronously void LoadThumbnail(const nsTArray<mozilla::dom::MediaImage>& aArtwork); // Stores the image at index aIndex of the mArtwork to the Thumbnail // asynchronously void LoadImageAtIndex(const size_t aIndex); // Stores the raw binary data of an image to mImageStream and set it to the // Thumbnail asynchronously void LoadImage(constchar* aImageData, uint32_t aDataSize); // Sets the Thumbnail to the image stored in mImageStream bool SetThumbnail(const nsAString& aUrl); void ClearThumbnail();
// Use mImageDataWriter to write the binary data of image into mImageStream // and refer the image by mImageStreamReference and then set it to the SMTC // interface
ComPtr<IDataWriter> mImageDataWriter;
ComPtr<IRandomAccessStream> mImageStream;
ComPtr<IRandomAccessStreamReference> mImageStreamReference;
ComPtr<IAsyncOperation<unsignedint>> mStoreAsyncOperation;
// mThumbnailUrl is the url of the current Thumbnail // mProcessingUrl is the url that is being processed. The process starts from // fetching an image from the url and then storing the fetched image to the // mImageStream. If mProcessingUrl is not empty, it means there is an image is // in processing // mThumbnailUrl and mProcessingUrl won't be set at the same time and they can // only be touched on main thread
nsString mThumbnailUrl;
nsString mProcessingUrl;
// mArtwork can only be used in main thread in case of data racing
CopyableTArray<mozilla::dom::MediaImage> mArtwork;
size_t mNextImageIndex;
// EventRegistrationTokens are used to have a handle on a callback (to remove // it again)
EventRegistrationToken mButtonPressedToken;
EventRegistrationToken mSeekRegistrationToken;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.