我知道使用
"& t = 0m25s"
从一开始将YouTube视频设置为25秒。但是,有人可以帮助我使用 YouTubePlayerSupportFragment
设置相同的功能这是我的代码
YouTubePlayerSupportFragment playerFragment = YouTubePlayerSupportFragment.newInstance();
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.fl_video, playerFragment).commit();
playerFragment.initialize(API_KEY, new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
player.play();
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult error) {
// YouTube error
String errorMessage = error.toString();
Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
Log.d("errorMessage:", errorMessage);
}
});
我找到了解决此问题的方法。有东西称为
cuevideo()
YouTubePlayerSupportFragment中的功能。
player.cueVideo("QYw77aNGXnE", 92000);
注意:92000对应于92秒(1分32秒),因为需要以毫秒为单位。