The class link ViewPlayer that’s the one: https://coding.net/u/lycam/p/lycamplus-android-ijkplayer-sdk/git/raw/master/sdk/LycamPlayer/ijkplayer/src/main/java/tv/lycam/ijkplayer/widget/PlayerView.java
The line 577 is a blank line, and therefore you must be using some different version. However, in the class constructor we have this:
settingsContainer = activity.findViewById(ResourceUtils.getResourceIdByName(mContext, "id", "simple_player_settings_container"));
settingsContainer.setVisibility(View.GONE);
The line with the setVisiblity gives the NullPointerException, and therefore the settingsContainer is null.
To the settingsContainer was null, is because the method findViewById failed. This method probably failed because the ResourceUtils.getResourceIdByName failed.
The code of ResourceUtils is here: https://coding.net/u/lycam/p/lycamplus-android-ijkplayer-sdk/git/raw/master/sdk/LycamPlayer/ijkplayer/src/main/java/tv/lycam/ijkplayer/utils/ResourceUtils.java
This is the code of the method in question:
public static int getResourceIdByName(Context context, String className, String name) {
int id = 0;
if (context == null) {
return id;
} else {
String packageName = context.getPackageName();
try {
String var10 = packageName + ".R$" + className;
Class desireClass = Class.forName(var10);
if (desireClass != null) {
id = desireClass.getField(name).getInt(desireClass);
}
} catch (ClassNotFoundException var7) {
Logger.e("ClassNotFoundException: class=%s fieldname=%s", className, name);
} catch (IllegalArgumentException var8) {
Logger.e("IllegalArgumentException: class=%s fieldname=%s", className, name);
} catch (SecurityException var9) {
Logger.e("SecurityException: class=%s fieldname=%s", className, name);
} catch (IllegalAccessException var101) {
Logger.e("IllegalAccessException: class=%s fieldname=%s", className, name);
} catch (NoSuchFieldException var11) {
Logger.e("NoSuchFieldException: class=%s fieldname=%s", className, name);
}
return id;
}
}
This method must have returned 0 because the field simple_player_settings_container class R.id of your pack VideoActivity3 was not found.
However, it is trying to access the contents of the layout file https://coding.net/u/lycam/p/lycamplus-android-ijkplayer-sdk/git/blob/master/sdk/LycamPlayer/ijkplayer/src/main/res/layout/simple_player_view_player.xml - That is, it is searching for the wrong layout file.
It is important to note that the class tv.lycam.ijkplayer.widget.IjkVideoView is the one that renders the video. But it renders only the video and nothing else. Already the class tv.lycam.ijkplayer.widget.PlayerView is responsible for rendering the video together. At least as far as I understand the code, that’s it, but I could be wrong.
Accordingly, the IjkVideoView needs the PlayerView to function. However, the PlayerView already includes the IjkVideoView in its layout.
In your layout XML you have this:
<include layout="@layout/simple_player_view_player"/>
This is not going to work. What you want is this:
<tv.lycam.ijkplayer.widget.PlayerView
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
The code of your VideoActivity3 will also have to have some changes:
public class VideoActivity3 extends Activity {
public final static String LOCATION3 = "com.compdigitec.VideoActivity3.location3";
public final static String mFilePath = "";
private PlayerView player;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
player = (PlayerView) View.inflate(this, R.layout.player, null);
setContentView(main);
Intent intent = getIntent();
String mFilePath = intent.getExtras().getString(LOCATION3);
}
@Override
protected void onResume() {
super.onResume();
player.setTitle("")
.setScaleType(PlayStateParams.fitparent)
.hideMenu(true)
.hideSteam(true)
.setForbidDoulbeUp(true)
.hideCenterPlayer(true)
.hideControlPanl(true)
.setPlaySource(mFilePath, true)
.startPlay();
}
@Override
public void onBackPressed() {
super.onBackPressed();
this.finish();
}
}
One thing that will still be pending is about these texts hardcoded in the simple_player_view_player.xml:
"您正在使用移动网络播放视频\n可能产生较高流量费用" must be exchanged for "Você está executando\no vídeo usando a rede móvel.\nIsso pode acarretar maiores\ncustos de tráfego de dados."
"继续" must be exchanged for "Play", "Rodar" or "Executar".
I believe there are two ways to exchange these texts for their equivalents in Portuguese:
At the end of the method onCreate of his VideoActivity3, put this:
LinearLayout a = (LinearLayout) findViewById(ResourceUtils.getResourceIdByName(player, "id", "app_video_netTie"));
((TextView) a.getChildAt(0)).setText("Você está executando\no vídeo usando a rede móvel.\nIsso pode acarretar maiores\ncustos de tráfego de dados.");
((TextView) a.getChildAt(1)).setText("Rodar");
Another way is to unpack the AAR, change them to exchange the texts in Chinese for Portuguese and then repack them.
Free, in this your code has no place defining the setVisibility() method. Put the code in which you are actually using method.
– viana
@Acklay is inside the builder of
PlayerViewwho gave the exception, class that is not his, but something that he imported.– Victor Stafusa
settingsContainer = activity.findViewById(ResourceUtils.getResourceIdByName(mContext, "id", "simple_player_settings_container"));
 settingsContainer.setVisibility(View.GONE);
– Free Flix
This inside the Playerview, which I’m importing from an Aar...
– Free Flix
Where did you find this class
PlayerView? Where is she now?– Victor Stafusa
The Playerview class can be seen at this link [https://coding.net/u/lycam/p/lycamplus-android-ijkplayer-sdk/git/raw/master/sdk/LycamPlayer/ijkplayer/src/main/java/tv/lycam/ijkplayer/widget/PlayerView.java] @Victorstafusa
– Free Flix
@Victorstafusa but then it gets hard O7 hehe
– viana