Hello, We are using Exo Player for a video music application but we have problem in using some features like fullscreen , repeat , select quality (or autmatically detect the best quality with users internet speed) , and how to get buffer size ? I appreciate any help.
www.b4x.com
It works fine... until I move the code in my B4XPage application.
Creating the second activity and moving current video from portrait to landscape are going well until KeyCode Back is pressed in the second (landscape) activity.
With debugging, issue is coming on line "Activity Finish" or "Return True"
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Log("Clic sur Full Screen")
If KeyCode = KeyCodes.KEYCODE_BACK Then
Dim Page2 As Video
Page2 = B4XPages.GetPage("Video") ' Accès aux constantes
Page2.PlayerVideo.Pause
CallSubDelayed("Video", "ReturnFullVideo")
Activity.Finish
End If
Return True
End Sub
I attached a picture with the code and the error message
Please could you help
I suspect that you have a structural problem with your app. B4XPages is a single activity with individual pages being Panels. You appear to be starting a second activity but then seem to treat that as part of B4XPages.
@agraham,
Thanks for your explanation
I did not understood that B4XPages supports only ONE single activity.
Yes, my application is using several (vertical) B4XPages. Unfortunately (I made the trial), it is not possible to get simultaneously lanscape and portrait with B4XPages (my video stays vertical). That's why I tried Erel's sample with 2 activities.
At the end, does that mean that it is not possible to get portrait and video in the same B4XPages app ?
Thanks,
Yes, it's a deliberate design choice by Erel to hide the activity lifecycle and avoid it's save and restore complications. You can hack it but it's messy and a bit pointless. You can still launch a separate activity and have that rotate but it won't be part of B4XPages and will need a manifest entry for that second activity to allow it to rotate.
Replace 'ActivityName' with the name of that activity module and start it with StartActivity(ActivityName). This Activity will be independent of the B4XPages activity and will have its own lifecycle events. You will be able, as always, to access the Process_Globals of Main and Starter.
PS. This is what I do with my BasicIDe where the Main Activity is limited to portrait orientation, just like B4xPages Main, but the launched second activity running the script is free to rotate.
This example demonstrates how you can add a full screen button to a video. Clicking on the button, starts a new landscape activity and it then uses the native switchTargetView method to reuse the same player in the new SimpleExoPlayerView. There is also some calculations involved with adding the...
Thanks for that link. I haven't had any need for Video, but the example is compact and illustrates several interesting techniques, including the above.
@agraham
Thanks. I understand your explanations end EREL's choice as well. I am not enough expert for hacking the system
@oparra
My understanding (and the sample you provided which is different from the one I started) is that it is possible to have landscape and portrait orientations when using B4XPages !!!!
I need to spend time to understand your code and the "PutLabelInVideoTopRightCorner" feature
The way to add the "full screen icon" inside the display is also very interesting
Thanks to all