openSource

abstract suspend fun openSource(sourceInfo: SourceInfo, loginStateChangeTimeout: Duration = LOGIN_STATE_CHANGE_TIMEOUT): UserFlowResult

Opens a media source. This is used when clicking the source at the source selection panel. If a source requires a login, this method performs the login user flow and opens the source in the case of success.

If a media source is ready for browsing, this method performs the browsing user flow. If UserFlowPolicy.browseSourceUserFlow provided by PolicyProvider.userFlowPolicy for a given sourceInfo is not null, it is performed, and this method suspends until the flow returns, usually after having opened a panel. If no custom browsing flow is provided, this method opens the source root panel and completes immediately.

If a media sourceInfo requires login, this method performs the login user flow and waits until it completes. If the UserFlowPolicy.loginUserFlow provided by PolicyProvider.userFlowPolicy for a given sourceInfo is not null, it is performed, and this method suspends until the flow finishes. For example it may wait until the bluetooth pairing panel is closed. If no custom login flow is provided, this method opens the login activity provided by the media source and waits until it finishes.

After the login flow is completed, this method suspends up to loginStateChangeTimeout waiting for the media source to become browsable. If the source becomes browsable within the loginStateChangeTimeout it is opened immediately, and this method finishes.

Return

UserFlowResult.Success if the source was opened successfully or UserFlowResult.Error otherwise.