MediaSource class

A source for a MediaType that will appear on the list of sources when set as active. Handles sourcing and delivery of arguments such that the MediaType is able to execute and launch with the proper arguments.

Implementers

Constructors

MediaSource({required String uniqueKey, required String sourceName, required String description, required MediaType mediaType, required IconData icon, required bool implementsSearch, required bool implementsHistory, bool overridesAutoImage = false, bool overridesAutoAudio = false})
Initialise a media source.

Properties

aspectRatio double
Aspect ratio of media items.
read-only
currentExtraData String?
This is used to hold data for generating images and audio.
read-only
currentMediaItem MediaItem
Supplies a media item that can be used for tracking and updating history, as well as generating video and audio with timestamp information. This should be uniquely implemented for each source. Some sources may want to generate their media item based on current playback information or progress.
read-only
currentSentence JidoujishoTextSelection
Supplies a sentence that can be used for the sentence field when making a card while this source is active. Can be set with setCurrentSentence and clearCurrentSentence in a source page.
read-only
description String
A longer description of what the source can do, or details left by or regarding the developer.
final
descriptionLocalisation Map<String, String>
Localisations for this source, where the key is a locale tag and the value is the description of the enhancement. If the value for the current locale is non-null, it will be used instead of description.
final
hashCode int
The hash code for this object.
read-onlyinherited
icon IconData
An icon that will show the enhancement if activated by the user in the quick menu.
final
implementsHistory bool
Whether or not this media source allows adding items to media history. Note that some media sources produce a history of media items but do not require this to be set true. For example, the reader fetches its history from a source other than the actual internal media history system provided by the media source framework. In such cases, this should be set as false. Setting this as true results to a media item being added to history when media is opened.
final
implementsSearch bool
Whether or not this media source has a search function. If false, this media source will have an action executed by onSearchBarTap.
final
mediaType MediaType
The media type that this source is for.
final
overridesAutoAudio bool
Whether or not a media source overrides the auto audio enhancement. See generateAudio.
final
overridesAutoImage bool
Whether or not a media source overrides the auto image enhancement. See generateImages.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
shouldGenerateAudio bool
Gets whether or not a media source should currently supply audio.
read-only
shouldGenerateImage bool
Gets whether or not a media source should currently supply images.
read-only
sourceName String
Name of the source that very shortly describes what it does.
final
sourceNameLocalisatiton Map<String, String>
Localisations for this source, where the key is a locale tag and the value is the sourceName of the source. If the value for the current locale is non-null, it will be used instead of sourceName.
final
uniqueKey String
A unique name that allows distinguishing this type from others, particularly for the purposes of differentiating between persistent settings keys.
final

Methods

buildBar() BaseMediaSearchBar?
Used to override the search bar if needed by a source that implements search.
buildHistoryPage() BasePage
The body widget to show in the tab when this source's media type and this source is selected.
buildLaunchPage({MediaItem? item}) BaseSourcePage
The widget to show when this source is launched. An optional MediaItem can be supplied as a launch parameter.
clearCurrentSentence() → void
Clear the current sentence.
clearExtraData() → void
Clear extra export data.
clearOverrideValues({required AppModel appModel, required MediaItem item}) Future<void>
Used to clear override values of a MediaItem upon deletion.
deletePreference({required String key}) Future<void>
Set the preference for a certain parameter key for this source.
generateAudio({required AppModel appModel, required MediaItem item, List<Subtitle>? subtitles, SubtitleOptions? options, String? data}) Future<File?>?
If this source is non-null, this will be used as the initial function for the audio field over the auto enhancement.
generateImages({required AppModel appModel, required MediaItem item, List<Subtitle>? subtitles, SubtitleOptions? options, String? data}) Future<List<NetworkToFileImage>>
If this source is non-null, this will be used as the initial function for the image field over the auto enhancement. Extra durations can be invoked and defined when initially opening the creator, to call attention to multiple durations to be used for image generation.
generateSearchSuggestions(String searchTerm) Future<List<String>>
Given a search term, this source may give search suggestions. If the empty list is returned, then search history will be shown instead.
getActions({required BuildContext context, required WidgetRef ref, required AppModel appModel}) List<Widget>
Get the floating search bar actions of this source when it is the active source being displayed on its respective media type tab.
getDisplaySubtitleFromMediaItem(MediaItem item) String
Given a MediaItem, return its subtitle. Some media items may allow overriding of values for display purposes. If a source does this, override this function.
getDisplayThumbnailFromMediaItem({required AppModel appModel, required MediaItem item, String? fallbackUrl, bool noOverride = false}) ImageProvider<Object>
Given a MediaItem, return its thumbnail. Some media items may allow overriding of values for display purposes.
getDisplayTitleFromMediaItem(MediaItem item) String
Given a MediaItem, return its title. Some media items may allow overriding of values for display purposes. If a source does this, override this function.
getLocalisedDescription(AppModel appModel) String
Get the best localisation for the description of this media source. If there is no localisation, the fallback is description.
getLocalisedSourceName(AppModel appModel) String
Get the best localisation for the label of this media source. If there is no localisation, the fallback is sourceName.
getOverrideThumbnailFilename({required AppModel appModel, required MediaItem item}) String
The map value used to store the override thumbnail of an item.
getOverrideThumbnailFromMediaItem({required AppModel appModel, required MediaItem item}) ImageProvider<Object>?
Given a MediaItem, return its override display thumbnail.
getOverrideTitleFromMediaItem(MediaItem item) String?
Given a MediaItem, return its override display title.
getOverrideTitleKey(MediaItem item) String
The map key used to store the override title of an item.
getPreference<T>({required String key, required T defaultValue}) → T
Get the preference value for a certain parameter key for this source.
getThumbnailUri({required AppModel appModel, required MediaItem item, bool noOverride = false}) String
Given a MediaItem, return its thumbnail. Some media items may allow overriding of values for display purposes.
initialise() Future<void>
This function is run at startup. It is not called again if already run.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onMediaItemClear(MediaItem item) Future<void>
This function can be used to clean up resources associated with a media item upon clearing it.
onSearchBarTap({required BuildContext context, required WidgetRef ref, required AppModel appModel}) Future<void>
If this is not null, this action is executed when the user taps on the search bar. Sources that do not have a search action should have this defined.
onSourceExit({required AppModel appModel, required BuildContext context, required WidgetRef ref}) Future<void>
Executed when this media source is closed. Perform this step to clean up resources or refresh media history.
prepareResources() Future<void>
If a media source requires resources to function, they can be prepared here and this function will be run once only at runtime during the initialisation step.
searchMediaItems({required BuildContext context, required String searchTerm, required int pageKey}) Future<List<MediaItem>?>
This returns a list of MediaItem, and is performed to search the media source for items.
setCurrentSentence({required JidoujishoTextSelection selection}) → void
Update the current sentence.
setExtraData(String? value) → void
Set extra export data. This should be simplified in the future and be used as the main way of communicating parameters to the creator for creating override images/audio information. There should not be media source specific parameters for general functions like generating images or audio.
setOverrideThumbnailFromMediaItem({required AppModel appModel, required MediaItem item, required File? file, required bool clearOverrideImage}) Future<void>
Given a MediaItem, set its override display thumbnail. If null, this deletes the override thumbnail.
setOverrideTitleFromMediaItem({required MediaItem item, required String? title}) Future<void>
Given a MediaItem, set its override display title. If the title is blank, the override title is cleared.
setPreference<T>({required String key, required T value}) Future<void>
Set the preference value for a certain parameter key for this source.
setShouldGenerateAudio({required bool value}) → void
Controls whether or not a media source should currently supply audio.
setShouldGenerateImage({required bool value}) → void
Controls whether or not a media source should currently supply images.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited