-2

How can I change whenever I need the Videoview URL using the Google Firebase Remote config method?

More details: I have a VideoView that uses URL to show video or stream but I want to be able to change these links whenever I need. Without having to create a new application update!

My activity:

package tk.protvapp.protv;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.MediaController;
import android.widget.VideoView;

public class FoxActivity extends Activity {
    VideoView myVideoView;
    View v;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_fox);

        myVideoView = (VideoView)this.findViewById(R.id.videofox1); MediaController mc = new MediaController(this); myVideoView.setMediaController(mc);
        final String urlStream = "//Search the link in remote config for paste here";
        myVideoView.start();
        myVideoView.findFocus();
        runOnUiThread(new Runnable() { @Override public void run() { myVideoView.setVideoURI(Uri.parse(urlStream)); } });
    }
    public void voltarhomefox(View v){
        Intent intent = new Intent(FoxActivity.this, HomeActivity.class);
        startActivity(intent);
    }
}

My Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000"
    tools:context="tk.protvapp.protv.FoxActivity">


    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:onClick="voltarhomefox"
        android:text="VOLTAR" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/button2"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:id="@+id/frameLayout">

        <VideoView
            android:id="@+id/videofox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </FrameLayout>

</RelativeLayout>
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441

1 Answers1

0

You can define a key in Remote Config Dashboard video_url = "https://foo.com/video.mp4" and fetch the value of video_url from your code using the getString("video_url") method.

Mayank Jain
  • 2,995
  • 2
  • 23
  • 19