Android Question ExoPlayer problem, black video

Lello1964

Well-Known Member
Licensed User
Longtime User
I have a problem using ExoPlayer 1.52.

I try open mp4 video, it will be loaded but black video appear, sometimes it's started but i don't know how.

What's problem ?

Thanks.

Raffaele
Main:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #MultiDex: True
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region


Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Private player1 As SimpleExoPlayer
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private exp1 As SimpleExoPlayerView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("panelpagamentonew")
   
    player1.Initialize("player1")
    player1.Prepare(player1.CreateLoopSource(player1.CreateFileSource(File.DirAssets,"video1.mp4"),-1))
   
    exp1.Player = player1
    player1.Play
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Player_Ready
    Log("Ready")
End Sub

Sub Player_Error (Message As String)
    Log("Error: " & Message)
End Sub

Sub Player_Complete
   
End Sub
 

Attachments

  • test.zip
    231.5 KB · Views: 106

Lello1964

Well-Known Member
Licensed User
Longtime User
The problem occurs when the layout is changed many times. I install it on an Android 7 device.
There are no errors, the Player_Complete event is executed.
But the screen is black.
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
I've tryed on my Smartphone Andoird 11 and it work,

but on Andorid 7 device black screen , sometimes it works after device reboot.

????
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
Works fine here (after I removed all the unused libraries).

Do you see any error in the logs?
I've tryed some project :

on my Friendly Arm nano-Pc T2 Android 7 device black video

on Smartphone android 10 - 11 done.
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
main:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #MultiDex: True
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false
#End Region


Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    'Private xui As XUI
    Private player1 As SimpleExoPlayer
    Private player2 As SimpleExoPlayer
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private exp1 As SimpleExoPlayerView
    Private exp2 As SimpleExoPlayerView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("panelpagamentonew")
   
    player1.Initialize("player1")
    player2.Initialize("player2")
   
    player1.Prepare(player1.CreateFileSource(File.DirAssets,"video1.mp4"))  
    player2.Prepare(player2.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
   
    exp1.Player = player1  
   
    exp2.Player = player2
   
    player1.Play
    player2.Play
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Player_Ready
    Log("Ready")
End Sub

Sub Player_Error (Message As String)
    Log("Error: " & Message)
End Sub

Sub Player_Complete

this s screen picture
 

Attachments

  • WhatsApp Image 2021-11-30 at 17.44.23.jpeg
    WhatsApp Image 2021-11-30 at 17.44.23.jpeg
    165.4 KB · Views: 121
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
First step is to switch to B4XPages. Your current code doesn't handle the activity life cycle correctly.
I can't, my apk is more more complex.

This is only a simply example to demostrate problem.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The more complex your project the more it is important to switch to B4XPages.

Try this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("panelpagamentonew")
   If FirstTime
    player1.Initialize("player1")
    player2.Initialize("player2")
    player1.Prepare(player1.CreateFileSource(File.DirAssets,"video1.mp4"))  
    player2.Prepare(player2.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
   End If

   
    exp1.Player = player1  
   
    exp2.Player = player2
   
    player1.Play
    player2.Play
   
End Sub
 
Upvote 0

Lello1964

Well-Known Member
Licensed User
Longtime User
The more complex your project the more it is important to switch to B4XPages.

Try this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("panelpagamentonew")
   If FirstTime
    player1.Initialize("player1")
    player2.Initialize("player2")
    player1.Prepare(player1.CreateFileSource(File.DirAssets,"video1.mp4")) 
    player2.Prepare(player2.CreateUriSource("https://html5demos.com/assets/dizzy.mp4"))
   End If

  
    exp1.Player = player1 
  
    exp2.Player = player2
  
    player1.Play
    player2.Play
  
End Sub

I will try to migrate to B4XPages
 
Upvote 0
Top