MediaItem class
An item representable in media history from which a media source may start playback with. This entity does not have any progress information, such as duration or number of chapters and individual progress of those items. That extra information is handled as extra arguments used alongside the MediaItem, and not included within it. This design is done to reduce the number and complexity of CRUD operations, as including all data in this entity is impractical to include when persisting a progress update.
- Annotations
-
- @JsonSerializable()
- @Collection()
Constructors
- MediaItem({required String mediaIdentifier, required String title, required String mediaTypeIdentifier, required String mediaSourceIdentifier, required int position, required int duration, required bool canDelete, required bool canEdit, Id? id, String? extraUrl, String? extra, String? base64Image, String? imageUrl, String? audioUrl, String? author, String? authorIdentifier, String? sourceMetadata})
- Initialise a media item with certain details.
-
MediaItem.fromJson(Map<
String, dynamic> json) -
Create an instance of this class from a serialized format.
factory
Properties
- audioUrl ↔ String?
-
Used to override the audio to be played for the media.
read / write
-
This field is a convenience field as it may be common to store this
detail. For a web video, this could be the channel where the video is
from. For a book, it is the author.
read / write
-
This field is for future-proofing, and can be used to store an identifier
for an author, for example, a YouTube channel.
read / write
- base64Image ↔ String?
-
If imageUrl is null and this is not null, this will be used as the
preview image.
read / write
- canDelete → bool
-
Whether or not this MediaItem can be deleted.
final
- canEdit → bool
-
Whether or not this MediaItem allows overriding the display title and
thumbnail.
final
- duration ↔ int
-
The media's full duration, used to be able to tell the completion of
this media context relative to the position.
read / write
- extra ↔ String?
-
This field is a convenience field for metadata information.
read / write
- extraUrl ↔ String?
-
Used to provide any extra URL information.
read / write
- hashCode → int
-
The hash code for this object.
read-onlyoverride
- id ↔ Id?
-
A unique identifier for the purposes of database storage.
read / write
- imageUrl ↔ String?
-
This will be attempted for use as the preview image if not null,
otherwise base64Image will be attempted.
read / write
- mediaIdentifier ↔ String
-
The media identifier of this item. Using this variable alone, a media
source must be able to functionally process how to display the media.
If the same item exists in history, then the item is replaced with a
newer item in the addition operation. This key is also used to identify
resources such as thumbnails in the cache.
read / write
- mediaSourceIdentifier ↔ String
-
The media source where this item is from.
read / write
- mediaTypeIdentifier ↔ String
-
The media type where this item is from.
read / write
- position ↔ int
-
The current progress of the media in the time this context was made.
This could be the seconds of a playing video or the page number of a
book or comic.
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- sourceMetadata ↔ String?
-
This field may be used to store additional details that the source may
require to get more details on this item.
read / write
- title ↔ String
-
The name of this item. Typically, this could be the name of a video
or a book.
read / write
- uniqueKey → String
-
A unique identifier for the purposes of database storage.
read-only
Methods
-
copyWith(
{int? id, String? mediaIdentifier, String? title, String? mediaSourceIdentifier, String? mediaTypeIdentifier, String? base64Image, String? imageUrl, String? audioUrl, String? author, String? sourceMetadata, int? position, int? duration, bool? canDelete, bool? canEdit}) → MediaItem - Creates a deep copy of this mapping but with the given variables replaced with the new values.
-
getMediaSource(
{required AppModel appModel}) → MediaSource - Get the MediaSource from a MediaItem from its serialised identifier.
-
getMediaType(
{required AppModel appModel}) → MediaType - Get the MediaType from a MediaItem from its serialised identifier.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Convert this into a serialized format.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override