Reputation:
I need to create a variable vVideo
. This variable is a class type of SurfaceViewRenderer
. This class
extends View
and implements another class who get a function onFrame
. I need to override this onFrame
.
Here is what I tried:
private var vVideo: SurfaceViewRenderer? = null
fun startConfigurationAudioVideo() {
vVideo = object : SurfaceViewRenderer(this) {
override fun onFrame(frame: VideoFrame?) {
Log.d("vVideo", "onFrame")
super.onFrame(frame)
}
}
vVideo = findViewById<SurfaceViewRenderer>(R.id.activity_display_videocast)
...
But, If I do this:
vVideo = object : SurfaceViewRenderer(this) {
override fun onFrame(frame: VideoFrame?) {
Log.d("vVideo", "onFrame")
super.onFrame(frame)
}
}
before this
vVideo = findViewById<SurfaceViewRenderer>(R.id.activity_display_videocast)
I don't have a surfaceRender.
And if I do inverse I don't get the Listener.
The problem is that I don't arrive to declare vVideo with her method onFrame and its surface (its View). The issue is that I can't have both in the same time.
Thanks for help!
Upvotes: 0
Views: 195
Reputation: 1428
You are creating and instantiating an anonymous class of SurfaceViewRenderer
and then you are getting the one on your interface, which is a different object.
To make this work, you would have to create a new class that extends SurfaceViewRenderer
and then use it on your layout.
Something like this:
package your.package.name
class SurfaceViewRendererWithFrameListener:SurfaceViewRenderer
{
override fun onFrame(frame: VideoFrame?)
{
Log.d("vVideo", "onFrame")
super.onFrame(frame)
}
}
Then use it on your layout:
<your.package.name.SurfaceViewRendererWithFrameListener
.../>
Upvotes: 4