I'm trying to resume a video on a cast device and need to set the startTime of one item.
I figured out that you need to set startTime on a queueItem and not the mediaInfo. loading a mediaInfo works fine but loading a queueList dose not, it throws a session_error and I don't know why.
"A session could not be created, or a session was invalid."
const context = cast.framework.CastContext.getInstance();
const {SESSION_STATE_CHANGED} = cast.framework.CastContextEventType
// initiate session
cast.framework.CastContext.getInstance().requestSession()
context.addEventListener(SESSION_STATE_CHANGED, () => {
switch (event.sessionState) {
case cast.framework.SessionState.SESSION_STARTED:
const castSession = cast.framework.CastContext.getInstance().getCurrentSession()
const queueItem = new chrome.cast.media.QueueItem(createMediaInfo(source));
queueItem.startTime = 50
const itemsToAdd = [queueItem]
const request = new chrome.cast.media.QueueLoadRequest(itemsToAdd);
castSession.loadMedia(request).then(console.log, console.error)
// Throws session_error --------^
break
case cast.framework.SessionState.SESSION_RESUMED:
// update ui
break
case cast.framework.SessionState.SESSION_ENDED:
// update ui
break
}
})
using the LoadRequest works fine but I can't set a startTime or set up a playlist with that.
const mediaInfo = createMediaInfo(source)
const request = new chrome.cast.media.LoadRequest(mediaInfo);
castSession.loadMedia(request).then(console.log, console.error)
from Getting ChromeCast session_error when trying to create a queue
No comments:
Post a Comment