Open kosso opened 1 year ago
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 artwork
property to the player initialisation which did appear before the Casting client gave up.)
@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. CastContext.getSharedInstance(this);
is no longer necessary in MainActivity.java. Plus I have updated these dependencies to last version:
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 !
@PhantomPainX Hi there. Thanks for this.
Here's a test stream : https://thisisamazing.tv/live.m3u8
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?
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
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 👍
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?
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 thatCastContext.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.