视频无法在WebView中播放,但播放音频

问题描述 投票:1回答:1

我在我的Android应用程序中使用DailyMotion SDK来加载我的应用程序中的dailymotion视频。问题是当我播放视频时,只有音频出现而不是视频。黑屏显示而不是视频。请提前帮助我。我的代码是

main activity.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>
java android android-webview dailymotion-api
1个回答
2
投票

如果您使用的是Android Studio的模拟器,则可能是因为您没有看到视频,只能看到音频。使用您的手机,您的视频可能会显示(如果您的代码是正确的)。所以不要使用模拟器来测试它。好运。

© www.soinside.com 2019 - 2024. All rights reserved.