createMediaSession
The createMediaSession
command is part of the Web SDK streamingMedia
component. You can use this component to collect data related to media sessions on your website. See the streamingMedia
documentation to learn how to configure this component.
The collected data can include information about media playbacks, pauses, completions, and other related events. Once collected, you can send this data to ÃÛ¶¹ÊÓƵ Analytics for Streaming Media, to aggregate metrics. This feature provides a comprehensive solution for tracking and understanding media consumption behavior on your website.
You can create media sessions in Web SDK in two ways:
- Automatically-tracked media sessions allow the Web SDK to manage the dispatch of media ping events to ÃÛ¶¹ÊÓƵ Analytics for Streaming Media. The frequency of these pings is determined by the configuration settings of the streamingMedia component.
- Manually-tracked media sessions give you more control over the dispatch of session ping events to ÃÛ¶¹ÊÓƵ Analytics for Streaming Media. Additionally, you have the ability to store the
sessionID
for media sessions.
Create an automatically-tracked media session automatic
To start tracking a media session automatically, call the createMediaSession
method with the options described below:
alloy("createMediaSession", {
playerId: "movie-test",
getPlayerDetails: () => {
return {
playhead: document.getElementById("movie-test").currentTime,
qoeDataDetails: {
bitrate: 1000,
startupTime: 1000,
fps: 30,
droppedFrames: 10
}
};
},
xdm: {
eventType: "media.sessionStart",
mediaCollection: {
sessionDetails: {
...
}
}
}
});
playerId
getPlayerDetails
playerId
provided.xdm.eventType
media.sessionStart
.xdm.mediaCollection.sessionDetails
sessionDetails
object should contain the session details properties. See the Media Collection schema documentation for more information.Create a manually-tracked media session manual
To start tracking a media session manually, call the createMediaSession
method with the options described below:
const sessionPromise = alloy("createMediaSession", {
xdm: {
eventType: "media.sessionStart",
mediaCollection: {
playhead: 0,
sessionDetails: {
...
},
qoeDataDetails: {
bitrate: 1000,
startupTime: 1000,
fps: 30,
droppedFrames: 10
}
}
}
});
xdm.eventType
media.sessionStart
.xdm.mediaCollection.sessionDetails
sessionDetails
object should contain the session details properties. See the Media Collection schema documentation for more information.xdm.mediaCollection.playhead
xdm.mediaCollection.qoeDataDetails