这是APP的Java代码:
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.IOException;
import android.media.AudioManager;
import android.media.MediaPlayer;
public class Player extends AppCompatActivity {
private MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
mp = new MediaPlayer();
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
try{
mp.setDataSource("http://69.175.58.196:80/stream");
mp.prepareAsync();
mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
}
catch (IOException e) {
e.printStackTrace();
}
}
}
这是AndroidManifest.xml的内容:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.goradio.ovoradioclub">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Player">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我似乎缺少与SE的相关的东西。 我也是Linux系统管理员,我知道与SE打交道的唯一方法是使用root Access。
该应用程序的想法是免费的,因此人们可以收听流,因此将设备扎根以使SE扎根不是我的选择。
我似乎缺少与SE的相关的东西。
我只是在Nexus 5上运行您的代码,运行Android 6.0。
getenforce
,在此设备上运行
adb shell
,显示
Enforcing
。流的播放很好。 Nexus 5x也是如此。 我毫不怀疑您在引用的设备上遇到问题。但是,看来SE执行状态是一个巧合,而不是您问题的实际来源。 您可能希望查看LogCat,以查看是否有任何有趣的消息。请注意,
MediaPlayer
您可能需要调整Android安全策略的SE或使用其他流媒体方法。尝试以下内容:
检查selinux拒绝(
logcat
),并在可能的情况下调整策略。
使用
dmesg | grep avc
(仅用于测试)将Selinux切换为宽松模式。
确保流媒体服务使用HTTPS和兼容编解码器。
CONSISSISSINGWEBRTC或外部层次以获得更好的兼容性。如果您正在寻找流式应用程序,则telelelatino