Как воспроизводить видео vemio в приложении для Android с помощью iframe?

Я использую сетевую видеобиблиотеку - https://github.com/vimeo/vimeo-networking-java Но не могу воспроизвести видео в моем приложении для Android. Я не знаю HTML iframe должным образом. По официальной ссылке он показывает:

   Video video = ...; // obtain a video in a manner described in the Requests section
   String html = video.embed != null ? video.embed.html : null;
   if(html != null) {
     // html is in the form "<iframe .... ></iframe>"
     // display the html however you wish
    }

Какой код мне нужно разместить здесь. Я не могу понять. Если вы знаете?


person Bhaskar Jyoti Dutta    schedule 06.04.2020    source источник


Ответы (1)


Для использования проигрывателя Vimeo в Iframe не требуется какая-либо библиотека. Вот пример:

Файл vimeoPlayer.java:

public class vimeoPlayer extends AppCompatActivity {
private WebView myWebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vimeo_player);
    myWebView=(WebView)findViewById(R.id.webview);
    WebSettings webSettings = myWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    myWebView.loadDataWithBaseURL("https://vimeo.com/47412289","<iframe src=\"https://player.vimeo.com/video/47412289\" width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>","text/html", "utf-8",null);


}
}

activity_vimeo_player.xml

     <?xml version="1.0" encoding="utf-8"?>
     <androidx.constraintlayout.widget.ConstraintLayout 
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:context=".vimeoPlayer">

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />


   </androidx.constraintlayout.widget.ConstraintLayout>

Файл AndroidManifest.xml

...
<uses-permission android:name="android.permission.INTERNET" />
...
person Olegario López    schedule 15.04.2020