Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use engage-sdk for continue watching #150

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vighnesh153
Copy link
Contributor

This Pull request integrates Engage SDK with TV samples app. In the current implementation, we are making use of androidx.tvprovider to update the Watch Next program row on a TV device. Since androidx.tvprovider is no longer maintained and we are now moving towards cross-device continue watching, we are migrating to making use of Engage SDK to publish to the watch next program row on a TV device.

@jpgpuyo
Copy link

jpgpuyo commented Feb 3, 2024

Hello @vighnesh153,
Thanks a lot for your effort.
I have tried reference app in Chromecast HD with Google TV and Play Next row is not working any more. I suspect that the issue is that in Google TV we have 'Continue watching' row instead of 'Play Next'.

Once this new SDK is integrated, can you clarify which is the compatibility with older TVs with 'Play next' row?

Thanks!

@vighnesh153
Copy link
Contributor Author

2 reasons why the integration isn't working:

  1. Engage SDK 1.4.0 version is not yet published engage-sdk-maven-repo
  2. Engage Service has an allowlisting mechanism at the backend to allow only certain apps to publish to tv provider. Currently, this Reference app is not yet allowlisted for publishing to TV provider.

@chikoski
Copy link
Contributor

chikoski commented Mar 6, 2024

I will review this PR, but I am not familiar with the API.

@miguelmontemayor Would you please review this PR if it uses API properly or not?

import com.google.android.engage.service.Intents.ACTION_PUBLISH_CONTINUATION

/** Broadcast Receiver to trigger a one time publish of clusters. */
class EngageServiceBroadcastReceiver : BroadcastReceiver() {
Copy link
Contributor

@chikoski chikoski Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering this Broadcast Receiver is not registered. Would you please double check it is registered dynamically or statically in the Manifest?


/**
* [EngageServiceWorker] is a [Worker] class that is tasked with publishing cluster
* requests to Engage Service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you please add a URL of the document describing context of using ServiceWorker to publish cluster requests?

import com.google.android.gms.tasks.Task
import com.google.android.gms.tasks.Tasks
import com.google.common.annotations.VisibleForTesting
import timber.log.Timber
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to replace Timber with the standard Log.

return Result.failure()
}

Timber.i("Checking for Engage Service availability")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to replace with Log.i

return Result.failure()
}

Timber.i("Engage Service is available. Proceeding to publish clusters")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to replace with Log.i

import com.android.tv.reference.watchnext.Publisher.publishContinuationClusters
import com.google.android.engage.service.Intents.ACTION_PUBLISH_CONTINUATION

/** Broadcast Receiver to trigger a one time publish of clusters. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to add a link to the document describing why BroadcastReceiver is necessary.

if ((playerState != WatchNextHelper.PLAY_STATE_PAUSED) and
(playerState != WatchNextHelper.PLAY_STATE_ENDED)
) {
Timber.e("Error.Invalid entry for Watch Next. Player state: $playerState")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to use Log.e

val workRequest =
PeriodicWorkRequest.Builder(
EngageServiceWorker::class.java,
/* repeatInterval= */ 24,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use named parameter here if we could.

PeriodicWorkRequest.Builder(
EngageServiceWorker::class.java,
/* repeatInterval= */ 24,
/* repeatIntervalTimeUnit= */ TimeUnit.HOURS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use named parameter here if we could.

import com.google.android.engage.video.datamodel.VideoEntity
import com.google.android.engage.video.datamodel.WatchNextType

object VideoToEngageEntityConverter {
Copy link
Contributor

@chikoski chikoski Jun 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object is useful as it shows how we can convert the data models for Client Side Play Next to the ones for Video Discovery At the same time, I am wondering if we should remove all Client Side Play Next code and replace them with the ones for Video Discovery API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the current implementation as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants