相关疑难解决方法(0)

Android YouTube API - 无缓冲处理方向更改

我正在使用Android YouTube API以纵向模式显示视频.在播放视频并将设备转换为横向模式时,视频将从现场停止但重新缓冲.我正在寻找一个解决方案,以避免重新缓冲.

我知道它可能是事实,因为谷歌在这里提供了一个例子,它完美无瑕地工作,除了我似乎无法使它与我的应用程序一起工作.我不确定要覆盖哪些函数以及哪些函数实际上删除了重新缓​​冲.

编辑:这是ListView中单元格的完整xml; 在最后一个TextView之后以编程方式添加YouTubePlayerView.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/youtube_ll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background_shape"
    android:orientation="vertical" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@drawable/header_background"
        android:weightSum="2" >

        <TextView
            android:id="@+id/youtube_username_tv"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="top|left"
            android:paddingLeft="15dp"
            android:paddingTop="8dp"
            android:paddingBottom="5dp"
            android:textColor="@android:color/darker_gray"
            android:textSize="13sp" />

        <TextView
            android:id="@+id/youtube_when_tv"
            android:layout_width="0px"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="top|right"
            android:paddingRight="15dp"
            android:paddingTop="8dp"
            android:paddingBottom="5dp"
            android:textColor="@android:color/darker_gray"
            android:textSize="13sp" />
    </LinearLayout>

    <TextView
        android:id="@+id/youtube_content_tv"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="20dp"
        android:paddingRight="17dp"
        android:paddingTop="8dp"
        android:paddingBottom="15dp"
        android:textSize="15sp" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我知道在java中你需要覆盖"onConfigurationChanged(Configuration newConfig)",也许还有"onFullscreen(boolean isFullscreen)",但你究竟是如何在没有重新缓冲的情况下"增长"youtube视图?我尝试使用全屏示例中的代码,但它似乎不适合我.这是玩家本身:

public class YouTubeParser extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener, YouTubePlayer.PlayerStateChangeListener, YouTubePlayer.OnFullscreenListener {

    private static final int …
Run Code Online (Sandbox Code Playgroud)

java android buffer youtube-api android-youtube-api

2
推荐指数
1
解决办法
6938
查看次数

标签 统计

android ×1

android-youtube-api ×1

buffer ×1

java ×1

youtube-api ×1