googlecast / CastVideos-android

Reference Android Sender w/ Framework API: CastVideos-android application shows how to cast videos from an Android device that is fully compliant with the Cast Design Checklist.
Apache License 2.0
345 stars 182 forks source link

ExpandedControllerActivity gives SQLiteDatabase exception #91

Open chinmaygghag opened 4 years ago

chinmaygghag commented 4 years ago

To give a gist of a scenario. I am using exoplayer to play the video and having a cast functionality. When I click on cast button, I have

mediaClient.registerCallback(new RemoteMediaClient.Callback() {
            @Override
            public void onStatusUpdated() {
                Intent intent = new Intent(VideoPlayer.this, ExpandedControlActivity.class);
                startActivity(intent);
                mediaClient.unregisterCallback(this);
            }

            @Override
            public void onMetadataUpdated() {
                super.onMetadataUpdated();
            }
        });

as in the sample application. This is how I build my mediaInfo

private MediaInfo buildMediaInfo(long playbackPositionMs, String thumbnailImage) {
        MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);

        movieMetadata.putString(MediaMetadata.KEY_TITLE, videoTitle);
        movieMetadata.addImage(new WebImage(Uri.parse(thumbnailImage)));
        try {
            return new MediaInfo.Builder(videoUrl)
                    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
                    .setContentType(isMp4(videoUrl)?"mp4":"hls")
                    .setMetadata(movieMetadata)
                    .setStreamDuration(playbackPositionMs)
                    .build();
        } catch (Exception e) {
            return new MediaInfo.Builder(videoUrl)
                    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
                    .setContentType(isMp4(videoUrl)?"mp4":"hls")
                    .setMetadata(movieMetadata)
                    .setStreamDuration(0)
                    .build();
        }
  }

I am not sure why but as soon as I click on the cast button I get this exception

2020-08-04 23:29:17.488 9161-6064/? E/SQLiteDatabase: Error inserting flex_time=3575000 job_id=-1 period=7152000 source=16 requires_charging=0 preferred_network_type=1 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService user_id=0 target_package=com.google.android.gms tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG task_type=0 required_idleness_state=0 service_kind=0 source_version=202614000 persistence_level=1 preferred_charging_state=1 required_network_type=0 runtime=1596608957468 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} last_runtime=0 android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067 SQLITE_CONSTRAINT_UNIQUE) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88) at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1599) at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1468) at aqne.a(:com.google.android.gms@202614037@20.26.14 (120400-320008519):175) at aqme.a(:com.google.android.gms@202614037@20.26.14 (120400-320008519):180) at aqme.a(:com.google.android.gms@202614037@20.26.14 (120400-320008519):22) at aqme.a(:com.google.android.gms@202614037@20.26.14 (120400-320008519):175) at aqio.run(:com.google.android.gms@202614037@20.26.14 (120400-320008519):9) at sil.b(:com.google.android.gms@202614037@20.26.14 (120400-320008519):12) at sil.run(:com.google.android.gms@202614037@20.26.14 (120400-320008519):7) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at sog.run(:com.google.android.gms@202614037@20.26.14 (120400-320008519):0) at java.lang.Thread.run(Thread.java:919)

Can someone please point me if I am missing something?