Skip to content

[QUESTION] Change starting offset time in custom manifest loader #1600

@mkochman

Description

@mkochman

Hi 👋
Is it possible to change start position during custom manifest loading?

So we want to start stream from certain position using loadVideo method, e.g.

Set base loadVideo config:

{
  autoPlay: true,
  startAt: { position: 10 },
  transport: "dash",
  url: "some url",
  manifestLoader: customManifestLoader
}

Parse manifest data and modify offset:

customManifestLoader = (manifestData, callback) => {
	const { url } = manifestInfo;
        const xhr = new XMLHttpRequest();
	const baseTime = performance.now();

  	xhr.onload = (r) => {
			if (200 <= xhr.status && xhr.status < 300) {
				let streamDuration = null;

			        function parseISODuration(duration: string): number {
				        .....
				        // parser logic
			        }
				const data = xhr.response;
				const mpdElement = data?.querySelector("MPD");
				streamDuration = mpdElement?.getAttribute("mediaPresentationDuration");
				...
				// Some logic based on duration
				...
		                // New start position value
		                // Best way to set a new start position?
			}
		};
  // Some manifest stuff
}

So far I have logic where loadVideo is called and then after stream is ready seekTo, so yep it's not the most efficient.

I will be grateful for your help ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions