-
Notifications
You must be signed in to change notification settings - Fork 46
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
CastContext.getSharedInstance(this) is deprecated. #132
Comments
Slight update to this regarding the crash when casting: It does appear to work when using a direct MP4 remote URL. Our use-case is live video using LL-HLS. The player on the device works fine with our remote LIVE url, but crashes when starting a Cast session. (I also added some test code to prevent the negative player position. I also added an |
@PhantomPainX can you please have a look at this issue as you implement the cast part of the plugin |
Hello, sorry for the late. Yeah, I knew about this error and I tried to solve it by implementing the method that Android Studio suggested but I couldn't get it to work and I left it with the old method since that was the only way to make it work. Tomorrow as I have a little time I'll try to fix it, but I really doubt it 😔 Last thing, this can be obvious, but if you find the solution, please share it with us in a PR 😁🙏 |
Ok, I got it to work now. build.gradle (plugin)
build.gradle (app)
Everything works fine, but with hls videos doesn't work on cast. I tried old-original code and these videos didn't work too, at least with the ones I have. @kosso can you provide me a functional video from your end to test it tomorrow? (I'm in Chile GMT-3) |
@PhantomPainX Hi there. Thanks for this. Here's a test stream : https://thisisamazing.tv/live.m3u8 |
Hi @PhantomPainX! com.google.android.exoplayer2 is deprecated, maybe it's a good idea to migrate to androidx.media3 (it's the same exoplayer, but another imports, etc). There's a shell script to help with the migration: https://developer.android.com/guide/topics/media/media3/getting-started/migration-guide |
@waltercruz thanks for providing the info. This will require a complete review of the code. May be the right time to write a complete new code may be in kotlin. This will take some time. Media3 bring a lot of new things which i have first to understand and play with. Anyhow thanks to point it out to us |
Sure, I know that these big changes require more time! Thanks for the plugin @jepiqueau ! |
Hey, sorry for not answering sooner, I've been very busy with my job and didn't have time to check the plugin with your video. Short answer, it didn't work. I was investigating and it is because the chromecast devices only support some audio and video codecs. You can check it here: https://developers.google.com/cast/docs/media So, your video may not be compatible with cast. I think you can transcode it in some backend service and use that source in your application. In the other hand as I said in my previous reply, I updated the exoplayer dependencies and now I have made some changes like hide the seekbar, progress textview, irrelevant buttons like prev, next, fast forward, rewind and show a LIVE label when the video is live streaming. Should I make a PR for this @jepiqueau @kosso or it is not necessary? |
Yeah, I noticed it when I updated the dependencies, almost everything became obsolete hahaha. I think the best will be to update to media3, but as Jep said, it requires reviewing all the code, the same way if the migration tool is used, since currently the plugin uses many deprecated functions that are not in line with the latest version of ExoPlayer and it is not recommended by the migration documentation. I'll check this when I have time, thanks for the info 👍 |
Hi @PhantomPainX ! I'm interested on the live label! And the updated instructions to chromecast support too, if available. |
HI @PhantomPainX ! Just got on the same problem that was reported on this issue, But I think that the problem is not the codec. Maybe it needs something slightly different on live streams? - (the live offset?) https://developer.android.com/guide/topics/media/exoplayer/live-streaming |
The documentation for Android'd ability to use Casting appears to be out of date.
After adding the line
CastContext.getSharedInstance(this); // <--- add this
,Android Studio complains that it is deprecated and that
CastContext.getSharedInstance(Context, Executor)
should be used.I have also tried implementing it this way using
CastContext.getSharedInstance(getApplicationContext(), Executors.newSingleThreadExecutor() );
but when I try to Cast to an Android TV, the app immediately crashes with :
java.lang.IllegalArgumentException: playPosition can not be negative: -672
For reference, this error is documented here :
https://developers.google.com/android/reference/com/google/android/gms/cast/framework/media/RemoteMediaClient#public-pendingresultremotemediaclient.mediachannelresult-queueinsertandplayitem-mediaqueueitem-item,-int-insertbeforeitemid,-long-playposition,-jsonobject-customdata
The video was playing fine on the device before attempting to Cast.
The text was updated successfully, but these errors were encountered: