MediaComposition
MediaComposition
MediaComposition
MediaComposition
Class
Definition
Represents a collection of media clips and background audio tracks.
public : sealed class MediaComposition : IMediaComposition, IMediaComposition2public sealed class MediaComposition : IMediaComposition, IMediaComposition2Public NotInheritable Class MediaComposition Implements IMediaComposition, IMediaComposition2// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Constructors
MediaComposition() MediaComposition() MediaComposition() MediaComposition()
Initializes a new instance of the MediaComposition class.
public : MediaComposition()public MediaComposition()Public Sub New()// You can use this method in JavaScript.
Properties
BackgroundAudioTracks BackgroundAudioTracks BackgroundAudioTracks BackgroundAudioTracks
A collection of background audio tracks for playback in the media composition.
public : IVector<BackgroundAudioTrack> BackgroundAudioTracks { get; }public IList<BackgroundAudioTrack> BackgroundAudioTracks { get; }Public ReadOnly Property BackgroundAudioTracks As IList<BackgroundAudioTrack>// You can use this property in JavaScript.
- Value
- IVector<BackgroundAudioTrack> IList<BackgroundAudioTrack> IList<BackgroundAudioTrack> IList<BackgroundAudioTrack>
The collection of BackgroundAudioTrack objects.
Clips Clips Clips Clips
A collection of media clips for playback in the media composition.
public : IVector<MediaClip> Clips { get; }public IList<MediaClip> Clips { get; }Public ReadOnly Property Clips As IList<MediaClip>// You can use this property in JavaScript.
- Value
- IVector<MediaClip> IList<MediaClip> IList<MediaClip> IList<MediaClip>
The collection of MediaClip objects.
Duration Duration Duration Duration
The total playback time of the media composition.
public : TimeSpan Duration { get; }public TimeSpan Duration { get; }Public ReadOnly Property Duration As TimeSpan// You can use this property in JavaScript.
- Value
- TimeSpan TimeSpan TimeSpan TimeSpan
The sum of the trimmed durations of all media clips in the composition.
OverlayLayers OverlayLayers OverlayLayers OverlayLayers
Gets the list of overlay layers for the media composition.
public : IVector<MediaOverlayLayer> OverlayLayers { get; }public IList<MediaOverlayLayer> OverlayLayers { get; }Public ReadOnly Property OverlayLayers As IList<MediaOverlayLayer>// You can use this property in JavaScript.
- Value
- IVector<MediaOverlayLayer> IList<MediaOverlayLayer> IList<MediaOverlayLayer> IList<MediaOverlayLayer>
The list of overlay layers for the media composition.
UserData UserData UserData UserData
An associative collection for storing custom properties associated with the media composition.
public : IMap<string, string> UserData { get; }public IDictionary<string, string> UserData { get; }Public ReadOnly Property UserData As IDictionary<string, string>// You can use this property in JavaScript.
- Value
- IMap<PlatForm::String, PlatForm::String> IDictionary<string, string> IDictionary<string, string> IDictionary<string, string>
The values stored in the IMap must be strings. These values are app-defined and are not used by the operating system. You can use this collection to store, for example, a description of the media composition.
Methods
Clone() Clone() Clone() Clone()
Creates a MediaComposition object that is identical to this instance.
public : MediaComposition Clone()public MediaComposition Clone()Public Function Clone() As MediaComposition// You can use this method in JavaScript.
A MediaComposition object that is a copy of this instance.
CreateDefaultEncodingProfile() CreateDefaultEncodingProfile() CreateDefaultEncodingProfile() CreateDefaultEncodingProfile()
Create a new default media encoding profile which can be modified if necessary.
public : MediaEncodingProfile CreateDefaultEncodingProfile()public MediaEncodingProfile CreateDefaultEncodingProfile()Public Function CreateDefaultEncodingProfile() As MediaEncodingProfile// You can use this method in JavaScript.
GenerateMediaStreamSource() GenerateMediaStreamSource() GenerateMediaStreamSource() GenerateMediaStreamSource()
Creates a new MediaStreamSource.
public : MediaStreamSource GenerateMediaStreamSource()public MediaStreamSource GenerateMediaStreamSource()Public Function GenerateMediaStreamSource() As MediaStreamSource// You can use this method in JavaScript.
The newly created MediaStreamSource.
- See Also
GenerateMediaStreamSource(MediaEncodingProfile) GenerateMediaStreamSource(MediaEncodingProfile) GenerateMediaStreamSource(MediaEncodingProfile) GenerateMediaStreamSource(MediaEncodingProfile)
Creates a new MediaStreamSource using the specified MediaEncodingProfile.
public : MediaStreamSource GenerateMediaStreamSource(MediaEncodingProfile encodingProfile)public MediaStreamSource GenerateMediaStreamSource(MediaEncodingProfile encodingProfile)Public Function GenerateMediaStreamSource(encodingProfile As MediaEncodingProfile) As MediaStreamSource// You can use this method in JavaScript.
The MediaEncodingProfile used to specify the encoding properties of the new MediaStreamSource.
The newly created MediaStreamSource.
- See Also
GeneratePreviewMediaStreamSource(Int32, Int32) GeneratePreviewMediaStreamSource(Int32, Int32) GeneratePreviewMediaStreamSource(Int32, Int32) GeneratePreviewMediaStreamSource(Int32, Int32)
Creates a new MediaStreamSource used to preview the edited media.
public : MediaStreamSource GeneratePreviewMediaStreamSource(int scaledWidth, int scaledHeight)public MediaStreamSource GeneratePreviewMediaStreamSource(Int32 scaledWidth, Int32 scaledHeight)Public Function GeneratePreviewMediaStreamSource(scaledWidth As Int32, scaledHeight As Int32) As MediaStreamSource// You can use this method in JavaScript.
- scaledWidth
- int Int32 Int32 Int32
The width of the preview media.
- scaledHeight
- int Int32 Int32 Int32
The height of the preview media.
The new MediaStreamSource used to preview the edited media.
GetThumbnailAsync(TimeSpan, Int32, Int32, VideoFramePrecision) GetThumbnailAsync(TimeSpan, Int32, Int32, VideoFramePrecision) GetThumbnailAsync(TimeSpan, Int32, Int32, VideoFramePrecision) GetThumbnailAsync(TimeSpan, Int32, Int32, VideoFramePrecision)
Asynchronously gets an image stream that represents a thumbnail of the media composition.
public : IAsyncOperation<ImageStream> GetThumbnailAsync(TimeSpan timeFromStart, int scaledWidth, int scaledHeight, VideoFramePrecision framePrecision)public IAsyncOperation<ImageStream> GetThumbnailAsync(TimeSpan timeFromStart, Int32 scaledWidth, Int32 scaledHeight, VideoFramePrecision framePrecision)Public Function GetThumbnailAsync(timeFromStart As TimeSpan, scaledWidth As Int32, scaledHeight As Int32, framePrecision As VideoFramePrecision) As IAsyncOperation( Of ImageStream )// You can use this method in JavaScript.
- timeFromStart
- TimeSpan TimeSpan TimeSpan TimeSpan
Specifies the point in the timeline of the MediaComposition from which to render the thumbnail, offset from the start of the MediaComposition.
- scaledWidth
- int Int32 Int32 Int32
Specifies the target width at which to render. The default is 0. scaledWidth and/or scaledHeight can be optional; see Remarks.
- scaledHeight
- int Int32 Int32 Int32
Specifies the target height at which to render. The default is 0. scaledWidth and/or scaledHeight can be optional; see Remarks.
Specifies the frame precision algorithm to use when retrieving the thumbnail.
An image stream representing resulting thumbnail.
Remarks
If scaledWidth and scaledHeight are both set, the aspect ratio of the original MediaComposition is ignored, and your values can alter the aspect ratio.
If either scaledWidth or scaledHeight but not both is specified, the value you provide controls that dimension but the aspect ratio is preserved (the other dimension is calculated based on factoring the original aspect ratio of the MediaComposition ).
GetThumbnailsAsync(IIterable, Int32, Int32, VideoFramePrecision)
GetThumbnailsAsync(IIterable, Int32, Int32, VideoFramePrecision)
GetThumbnailsAsync(IIterable, Int32, Int32, VideoFramePrecision)
GetThumbnailsAsync(IIterable, Int32, Int32, VideoFramePrecision)
Asynchronously gets a vector view of thumbnails of the media composition.
public : IAsyncOperation<IVectorView<ImageStream>> GetThumbnailsAsync(IIterable<TimeSpan> timesFromStart, int scaledWidth, int scaledHeight, VideoFramePrecision framePrecision)public IAsyncOperation<IReadOnlyList<ImageStream>> GetThumbnailsAsync(IEnumerable<TimeSpan> timesFromStart, Int32 scaledWidth, Int32 scaledHeight, VideoFramePrecision framePrecision)Public Function GetThumbnailsAsync(timesFromStart As IEnumerable<TimeSpan>, scaledWidth As Int32, scaledHeight As Int32, framePrecision As VideoFramePrecision) As IAsyncOperation( Of IReadOnlyListImageStream )// You can use this method in JavaScript.
- timesFromStart
- IIterable<TimeSpan> IEnumerable<TimeSpan> IEnumerable<TimeSpan> IEnumerable<TimeSpan>
Specifies the points in the timeline of the MediaComposition from which to render the thumbnails, offset from the start of the MediaComposition.
- scaledWidth
- int Int32 Int32 Int32
Specifies the target width at which to render. The default is 0. scaledWidth and/or scaledHeight can be optional; see Remarks.
- scaledHeight
- int Int32 Int32 Int32
Specifies the target height at which to render. The default is 0. scaledWidth and/or scaledHeight can be optional; see Remarks.
Specifies the frame precision algorithm to use when retrieving the thumbnails.
A vector view on the resulting thumbnails.
Remarks
If scaledWidth and scaledHeight are both set, the aspect ratio of the original MediaComposition is ignored, and your values can alter the aspect ratio.
If either scaledWidth or scaledHeight but not both is specified, the value you provide controls that dimension but the aspect ratio is preserved (the other dimension is calculated based on factoring the original aspect ratio of the MediaComposition ).
LoadAsync(StorageFile) LoadAsync(StorageFile) LoadAsync(StorageFile) LoadAsync(StorageFile)
Asynchronously loads a MediaComposition from a StorageFile.
public : static IAsyncOperation<MediaComposition> LoadAsync(StorageFile file)public static IAsyncOperation<MediaComposition> LoadAsync(StorageFile file)Public Static Function LoadAsync(file As StorageFile) As IAsyncOperation( Of MediaComposition )// You can use this method in JavaScript.
The file from which to load the MediaComposition.
An async operation which can be used to track the success or failure of the operation.
Remarks
This method allows you to load a composition from an XML file you saved with a previous call to SaveAsync. Once you have loaded the composition, you can make changes to the composition and either save it again or render it to a video file by calling RenderToFileAsync.
RenderToFileAsync(IStorageFile) RenderToFileAsync(IStorageFile) RenderToFileAsync(IStorageFile) RenderToFileAsync(IStorageFile)
Asynchronously renders the MediaComposition to the specified file.
public : IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination)public IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination)Public Function RenderToFileAsync(destination As IStorageFile) As IAsyncOperationWithProgress( Of TranscodeFailureReason, double )// You can use this method in JavaScript.
- destination
- IStorageFile IStorageFile IStorageFile IStorageFile
The file to which this MediaComposition is rendered.
An async operation which can be used to track the success or failure of the operation.
Remarks
This method saves the composition to a video file that can be played back with standard media players. If you want to save the composition as an XML file that can be loaded and modified in the future, use SaveAsync.
- See Also
-
RenderToFileAsync(IStorageFile, MediaTrimmingPreference)RenderToFileAsync(IStorageFile, MediaTrimmingPreference)RenderToFileAsync(IStorageFile, MediaTrimmingPreference)RenderToFileAsync(IStorageFile, MediaTrimmingPreference)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)
RenderToFileAsync(IStorageFile, MediaTrimmingPreference) RenderToFileAsync(IStorageFile, MediaTrimmingPreference) RenderToFileAsync(IStorageFile, MediaTrimmingPreference) RenderToFileAsync(IStorageFile, MediaTrimmingPreference)
Asynchronously renders the MediaComposition to a specified file using the indicated media trimming preference.
public : IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination, MediaTrimmingPreference trimmingPreference)public IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination, MediaTrimmingPreference trimmingPreference)Public Function RenderToFileAsync(destination As IStorageFile, trimmingPreference As MediaTrimmingPreference) As IAsyncOperationWithProgress( Of TranscodeFailureReason, double )// You can use this method in JavaScript.
- destination
- IStorageFile IStorageFile IStorageFile IStorageFile
The file to which this MediaComposition is rendered.
- trimmingPreference
- MediaTrimmingPreference MediaTrimmingPreference MediaTrimmingPreference MediaTrimmingPreference
Specifies whether to be fast or precise when trimming the media.
An async operation which can be used to track the success or failure of the operation.
Remarks
This method saves the composition to a video file that can be played back with standard media players. If you want to save the composition as an XML file that can be loaded and modified in the future, use SaveAsync.
- See Also
-
RenderToFileAsync(IStorageFile)RenderToFileAsync(IStorageFile)RenderToFileAsync(IStorageFile)RenderToFileAsync(IStorageFile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)
RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile) RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile) RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile) RenderToFileAsync(IStorageFile, MediaTrimmingPreference, MediaEncodingProfile)
Asynchronously renders the MediaComposition to a specified file using the indicated media trimming preference and encoding profile.
public : IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination, MediaTrimmingPreference trimmingPreference, MediaEncodingProfile encodingProfile)public IAsyncOperationWithProgress<TranscodeFailureReason, double> RenderToFileAsync(IStorageFile destination, MediaTrimmingPreference trimmingPreference, MediaEncodingProfile encodingProfile)Public Function RenderToFileAsync(destination As IStorageFile, trimmingPreference As MediaTrimmingPreference, encodingProfile As MediaEncodingProfile) As IAsyncOperationWithProgress( Of TranscodeFailureReason, double )// You can use this method in JavaScript.
- destination
- IStorageFile IStorageFile IStorageFile IStorageFile
The file to which this MediaComposition is rendered.
- trimmingPreference
- MediaTrimmingPreference MediaTrimmingPreference MediaTrimmingPreference MediaTrimmingPreference
Specifies whether to be fast or precise when trimming the media.
Specifies the encoding profile to use for rendering the media.
An async operation which can be used to track the success or failure of the operation.
Remarks
This method saves the composition to a video file that can be played back with standard media players. If you want to save the composition as an XML file that can be loaded and modified in the future, use SaveAsync.
SaveAsync(IStorageFile) SaveAsync(IStorageFile) SaveAsync(IStorageFile) SaveAsync(IStorageFile)
Asynchronously serializes the MediaComposition to disk so that it can be loaded and modified in the future.
public : IAsyncAction SaveAsync(IStorageFile file)public IAsyncAction SaveAsync(IStorageFile file)Public Function SaveAsync(file As IStorageFile) As IAsyncAction// You can use this method in JavaScript.
The file to which the MediaComposition is saved.
An async action which can be used to track the success or failure of the operation.
Remarks
This method saves the composition as an XML file containing metadata about the composition such as the source media files, arrangement of clips, overlays, and effects applied to the composition. A new media composition can be created from the saved XML file by calling LoadAsync.
To render a media composition as a video file so that it can be played back by standard media players, use the RenderToFileAsync method.