1

I am using DailyMotion SDK in my android app to load the dailymotion videos in my app. The problem is when I play the video, Only audio is coming out but not video. Black screen is showing instead of video. Please help me this thanks in advance. My codes are

MainActivity.java

package com.example.rajeshkumarreddy.videoplayered;
import android.graphics.Color; 
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import com.dailymotion.android.player.sdk.PlayerWebView;
import java.util.HashMap;
import java.util.Map;

public class DailyMotionActivity extends AppCompatActivity {
    PlayerWebView playerWebView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    playerWebView=(PlayerWebView)findViewById(R.id.dm_player_web_view);
    playerWebView.load("x1owz8e");

  }

}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="com.example.rajeshkumarreddy.videoplayered.MainActivity">

<com.dailymotion.android.player.sdk.PlayerWebView
    android:id="@+id/dm_player_web_view"
    android:layout_width="match_parent"
    android:layout_height="215dp">
</com.dailymotion.android.player.sdk.PlayerWebView>



</RelativeLayout>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

2

If you are using Android Studio's emulator, this can be the cause you are not seeing the video, only audio is perceived. Use your phone, there your video probably will show (if your code is correct). So don't use the emulator to test this. Best luck.

statosdotcom
  • 3,109
  • 2
  • 17
  • 40
moezsf
  • 21
  • 1
0

Thanks to this answer, I was able to solve the issue with webview.

Code you need to create WebView:

    private fun createWebView(iframeCode: String): WebView {
    val webView = WebView(this.requireContext())
    webView.layoutParams = LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.WRAP_CONTENT,
        LinearLayout.LayoutParams.WRAP_CONTENT
        ).apply {
        setMargins(0, 0, 0, 32.dp)
    }
    webView.setBackgroundColor(Color.TRANSPARENT)
    webView.setLayerType(View.LAYER_TYPE_HARDWARE, null)
    webView.webViewClient = WebViewClient()
    webView.webChromeClient = WebChromeClient()
    webView.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY
    webView.settings.setSupportZoom(false)
    webView.settings.builtInZoomControls = false
    webView.settings.displayZoomControls = false
    webView.settings.loadsImagesAutomatically = true
    webView.settings.javaScriptEnabled = true
    webView.settings.javaScriptCanOpenWindowsAutomatically = true
    webView.settings.pluginState = PluginState.ON_DEMAND

    webView.loadData(iframeCode, "text/html", "UTF-8")

    return webView
}