Android Question MediaPlayerStream for 3gp streaming

Ratna Fang

Member
Licensed User
Longtime User
hi,

i have simple code using audio lib 1.60 (default b4a 3.5)
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Video1 As MediaPlayerStream
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Video1.Initialize("Video1")
 
 
    'load streaming
    Video1.Load("http://118.97.77.157/m/video/JICT.3gp") 
 
End Sub


Sub Video1_StreamReady
    Log("starts playing")
    Video1.Play
End Sub

Sub Video1_StreamError (ErrorCode As String, ExtraData As Int)
    Log("Error: " & ErrorCode & ", " & ExtraData)
    ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub

Sub Video1_StreamBuffer(Percentage As Int)
    Log(Percentage)
End Sub

the code is compiled successfully without any errors. i installed to genymotion emulator and a real device. unfortunately, i can't get the video played. there is only a blank screen without any errors.

i checked the log, and i got many 100 and starts playing.

something missing?

please kindly help. the 3gp link is fine and working.
 

susu

Well-Known Member
Licensed User
Longtime User
You forgot to add VideoView into Activity.
 
Upvote 0

Ratna Fang

Member
Licensed User
Longtime User
You forgot to add VideoView into Activity.

hi susu :)

now i change the code like this. i add activity.adview in activity_create.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Video1 As MediaPlayerStream
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Video1.Initialize("Video1")
   
   
   
    'load streaming
    Video1.Load("http://118.97.77.157/m/video/JICT.3gp")
    Activity.AddView(Video1,10dip,10dip,200dip, 200dip)
    'Video.Play
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Video1_StreamReady
    Log("starts playing")
    Video1.Play
End Sub
Sub Video1_StreamError (ErrorCode As String, ExtraData As Int)
    Log("Error: " & ErrorCode & ", " & ExtraData)
    ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub
Sub Video1_StreamBuffer(Percentage As Int)
    Log(Percentage)
End Sub

but i have error when compiling like this:
B4X:
Parsing code.                          0.00
Compiling code.                        0.02
Compiling layouts code.                0.00
Generating R file.                      0.23
Compiling generated Java code.          Error
B4A line: 37
Activity.AddView(Video1,10dip,10dip,200dip, 200dip)
javac 1.7.0_03
src\contoh\video\player\main.java:280: error: inconvertible types
mostCurrent._activity.AddView((android.view.View)(mostCurrent._video1),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (10)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (200)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (200)));
                                                ^
  required: View
  found:    MediaPlayerStreamWrapper
1 error

i just use core and audio libs. no other libs are loaded.
 
Upvote 0

Ratna Fang

Member
Licensed User
Longtime User
thanks erel. but i got the error "cant play this video".
my code now is like this:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Video1.Initialize("Video1")
   
    'load lgs play kalo streaming
    Video1.LoadVideo("http", "http://118.97.77.157/m/video/Gereja_Katedral_Semarang.3gp")
    Activity.AddView(Video1,10dip,10dip,200dip, 200dip)
    Video1.Play
   
End Sub
 
Upvote 0

Ajay Kakar

Member
Licensed User
Longtime User
Erel,

I have tried the above with 10 different kinds of video files. None of them play on 6 different Android. I very badly need to play a video file in my app. I can create a video file of any format. Please tell me which format will work.

Ajay
 
Upvote 0
Top