Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
610 views
in Technique[技术] by (71.8m points)

casting - Android: MediaRouteButton is disabled by default

I am trying to implement cast to tv feature using MediaRouteButton and exoPlayer. I have a strange issue with MediaRouteButton, I just followed this tutorial and implemented MediaRouteButton as a view not as part of the menu. Here what I have done till now, but after running the app, the MediaRouteButton is disabled.

This is layout:

<androidx.mediarouter.app.MediaRouteButton
    android:id="@+id/media_route_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:mediaRouteTypes="user"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
     />

This is kotlin code inside activity:

class TestActivity : AppCompatActivity() {
    
    //var APP_ID = "4F8B3483"
    var mMediaRouteButton: MediaRouteButton? = null
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test)

        mMediaRouteButton =  findViewById(R.id.media_route_button);

        CastContext.getSharedInstance(this);
        CastButtonFactory.setUpMediaRouteButton(this, mMediaRouteButton);
        
    }
}

Any suggestions?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

MediaRouteButton will be visible to you on the screen , when your device and casting device is connecting to the same Network .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...