我在我的原生Android应用中使用YouTubeAndroidPlayerApi-1.2.2作为电影播放器。我的应用程序正在使用kiosk模式,播放器是ui的一部分。首先在启动应用程序启动后作为主页播放视频。但启动后没有声音,只有视频。几分钟后,如果重新启动我的应用程序,那么再次有声音和视频。
Android版:6 YT播放器:YouTubeAndroidPlayerApi-1.2.2 playermode:YouTubePlayer.PlayerStyle.CHROMELESS
我不会做我正在做的事情并且正在寻找一段时间的错误。有人能说出我失踪了吗?
提前thx!Lutfi Uzun
更新
清单:
timedelta
活动:
公共课ManasMaestro扩展YouTubeBaseActivity实施YouTubePlayer.OnInitializedListener {
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<activity
android:name=".ManasMaestro"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
</activity>
}
@Override
protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
YouTubePlayerView _playerView = (YouTubePlayerView)findViewById(R.id.player_view);
_playerView.initialize(mYoutubeKey, this);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult errorReason) {
Log.e("on", String.format("%s, Error: %s", getString(R.string.error_failed), YouTubeInitializationResultHelper.getError(errorReason).toString()));
isYoutubePlayerReady = false;
}
private final YouTubePlayer.PlaybackEventListener playbackEventListener = new YouTubePlayer.PlaybackEventListener() {
@Override
public void onBuffering(boolean arg0) {
// Log.e("on", "onBuffering");
}
@Override
public void onPaused() {
if (appSettings.isWifi() && !mYouTubePlayer.isPlaying()) {
mYouTubePlayer.play();
}
}
@Override
public void onPlaying() {
Log.e("on", "onPlaying");
//LUTFI
if(mCurrentPlayingVideo != null)
{
// save current playing...
if(mVideoCDCover != null)
{
//mVideoCDCover
Glide.with(getBaseContext())
.load(mCurrentPlayingVideo.getThumbnailMediumURL())
//.override(130, 94)
.centerCrop()
.placeholder(R.drawable.avatar_loading)
.error(R.drawable.avatar_error)
.into(mVideoCDCover);
}
PlayHistoryVO item = new PlayHistoryVO();
item.setPlayDate(new DateTime(System.currentTimeMillis()));
item.setVideoId(mCurrentPlayingVideo.getVideoId());
mPlayHistory.add(item);
}
}
@Override
public void onSeekTo(int arg0) {
//Log.e("on", "onSeekTo");
}
@Override
public void onStopped() {
Log.e("on", "onStopped");
}
};
private final YouTubePlayer.PlayerStateChangeListener playerStateChangeListener = new YouTubePlayer.PlayerStateChangeListener() {
@Override
public void onLoading() {
Log.e("on", "onLoading");
}
@Override
public void onLoaded(String s) {
Log.e("on", "onLoaded");
}
@Override
public void onAdStarted() {
Log.e("on", "onAdStarted");
}
@Override
public void onVideoStarted() {
Log.e("on", "onVideoStarted");
}
@Override
public void onVideoEnded() {
Log.e("on", "onVideoEnded");
// There is no payed music playing
isPlayingPayedVideo = false;
// play next if there is one...
playNextFromList();
}
@Override
public void onError(YouTubePlayer.ErrorReason errorReason) {
Log.e("on", String.format("YouTubePlayer - onError : %s", YouTubePlayerErrorReasonHelper.getError(errorReason)));
}
};