Android Question Videoview Extension

MarcoRome

Expert
Licensed User
Longtime User
Hi @warwound thank for this great library
when i insert in Activity 100%x, 100%y i have effect stretched.
Is it possible type Gravity.Center effect ?
Thank you very much for your response
Marco
 

victormedranop

Well-Known Member
Licensed User
Longtime User
and how to reduce size ?
FFMpegVideoView1.SetVideoLayout(FFMpegVideoView1.VIDEO_LAYOUT_STRETCH)

is not working.

Victor
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
and how to reduce size ?
FFMpegVideoView1.SetVideoLayout(FFMpegVideoView1.VIDEO_LAYOUT_STRETCH)

is not working.

Victor
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 vv_sopra_pannello As VideoViewExt
    Dim Panel_Wait As Panel
    Dim immagine_pannello As ImageView
    Dim w,h As Int

       
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    ......
    File.Copy(File.DirAssets, "vid_bokeh.mp4", File.DirInternal, "vid_bokeh.mp4")
         
   
   
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lay_partenza")

   
    'Wait that download...
    vv_sopra_pannello.Initialize("vv_sopra_pannello")
    vv_sopra_pannello.LoadVideo(File.DirInternal, "vid_bokeh.mp4")

   
    'Calculation Proportion Movie
      Dim vidfile, Dir, VideoName As String
      Dir = File.DirInternal
      VideoName = "vid_bokeh.mp4"
      vidfile = File.Combine(Dir, VideoName)
   
      Dim rfl As Reflector
      Dim obj As Object
      Dim b As Bitmap
   
      obj = rfl.CreateObject("android.media.MediaMetadataRetriever")
      rfl.Target = obj
      rfl.RunMethod2("setDataSource", vidfile, "java.lang.String")
      b = rfl.RunMethod3("getFrameAtTime", 0, "java.lang.long", 3, "java.lang.int")
   
   
      Dim new_width, new_height As Int

If ( b.Width / b.Height < Activity.Width / Activity.Height ) Then 'Landscape
            new_width = Activity.Width + 100dip
            new_height = b.Height * ( Activity.Width / b.Width )
            Panel_Wait.AddView(vv_sopra_pannello, 0, 0, new_width,new_height )    
    Else
            new_height = Activity.Height + 100dip
            new_width = b.Width * ( Activity.Height / b.Height)
            Panel_Wait.AddView(vv_sopra_pannello, - ( new_width / 2 ) + ( Activity.Width / 2) , - (( new_height / 2 ) - ( Activity.Height / 2 )),  new_width,new_height )

End If
   
    'End Calculation Proportion movie
    .......
 
Upvote 0

victormedranop

Well-Known Member
Licensed User
Longtime User
What I am trying to do is change aspect ratio of the view playing a video with FFMPEG library.
reduce 20%.
try inside a panel but did not work.

Victor
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
What I am trying to do is change aspect ratio of the view playing a video with FFMPEG library.
reduce 20%.
try inside a panel but did not work.

Victor
You can start with this code:

B4X:
   'Calculation Proportion Movie
      Dim vidfile, Dir, VideoName As String
      Dir = File.DirInternal
      VideoName = "vid_bokeh.mp4"
      vidfile = File.Combine(Dir, VideoName)
  
      Dim rfl As Reflector
      Dim obj As Object
      Dim b As Bitmap
  
      obj = rfl.CreateObject("android.media.MediaMetadataRetriever")
      rfl.Target = obj
      rfl.RunMethod2("setDataSource", vidfile, "java.lang.String")
      b = rfl.RunMethod3("getFrameAtTime", 0, "java.lang.long", 3, "java.lang.int")
  
  
      Dim new_width, new_height As Int

If ( b.Width / b.Height < Activity.Width / Activity.Height ) Then 'Landscape
            new_width = Activity.Width + 100dip
            new_height = b.Height * ( Activity.Width / b.Width )
            Panel_Wait.AddView(vv_sopra_pannello, 0, 0, new_width,new_height )   
    Else
            new_height = Activity.Height + 100dip
            new_width = b.Width * ( Activity.Height / b.Height)
            Panel_Wait.AddView(vv_sopra_pannello, - ( new_width / 2 ) + ( Activity.Width / 2) , - (( new_height / 2 ) - ( Activity.Height / 2 )),  new_width,new_height )

End If

This is proportional for all screen, but you can reduce or increase example:
B4X:
.....
          new_height = b.Height - ((20/b.Height) * b.Height) .......'Reduce 20%
          new_width = b.Width - ((20/b.Width) * b.Width) .......'Reduce 20%
          Panel_Wait.AddView(vv_sopra_pannello,...... - ( new_width / 2 ) + ( Activity.Width / 2) , - (( new_height / 2 ) - ( Activity.Height / 2 )),  new_width,new_height )
.....
 
Upvote 0
Top