Android Question exoplayer about Loop Playback and exit without background play

cup319

Member
1、i need to repaly one mp4 file play again again again ,has any way to realize it by for ???


2、 i had write an sample player,just do the thing just play one mp4 file for my mother. it can work but it had something wrong ,when i exit on my device or tv ,it stil will play backgroud with sound .
here are the codes:
use the exoplayer example file


#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SimpleExoPlayerView1 As SimpleExoPlayerView
Private player1 As SimpleExoPlayer
End Sub

Public Sub Initialize

End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
player1.Initialize("player")
Dim sources As List
sources.Initialize
'sources.Add(player1.CreateHLSSource("http://kuqq.tk/00/huya.php?id=11342412"))
player1.Prepare(player1.CreateFileSource(File.DirAssets, "yjjn.flv"))
'player1.Prepare(player1.CreateListSource(sources))
SimpleExoPlayerView1.Player = player1
player1.Play
End Sub

Sub Player_Ready
Log("Ready")
End Sub

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

Sub Player_Complete
Log("complete")
End Sub
 

Attachments

  • vedio-app.zip
    22 KB · Views: 219

cup319

Member
Please use [code]code here...[/code] tags when posting code.
CODE ABOUT EVOPLAYER:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
    Private player1 As SimpleExoPlayer
End Sub

Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    player1.Initialize("player")
    Dim sources As List
    sources.Initialize
    'sources.Add(player1.CreateHLSSource("http://kuqq.tk/00/huya.php?id=11342412"))
    player1.Prepare(player1.CreateFileSource(File.DirAssets, "yjjn.flv"))
    'player1.Prepare(player1.CreateListSource(sources))
    SimpleExoPlayerView1.Player = player1
    player1.Play
End Sub

Sub Player_Ready
    Log("Ready")
End Sub

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

Sub Player_Complete
    Log("complete")
End Sub
 
Upvote 0

cup319

Member
1.
B4X:
player1.Prepare(player1.CreateLoopSource(player1.CreateFileSource(File.DirAssets, "yjjn.flv"), -1)

2. Handle the B4XPage_Background event and stop playback.
THANKS
I WILL TRY IT
微信截图_20211109111807.png
 
Upvote 0
Top