Unable to play mp4 with VideoView

metrick

Active Member
Licensed User
Longtime User
I have try several difference encode and size of the video from avi to difference format of MP4, using the codes below to play the video.
Always get message "Cannot play video Sorry, this video cannot be played"

I have also tried mp4 file taken from camera and still said that the video cannot be played.
Note: the video play file in the camera.

Any body has a working codes that can play mp4 file and would like to share would be very much appreciated.

Sorry, can't do stackoverflow yet, will take a look later



Sub Globals
Dim vv As VideoView
End Sub
Sub Activity_Create(FirstTime As Boolean)
vv.Initialize("vv")
Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
vv.LoadVideo(File.DirInternal, "MyFile.mp4")
vv.Play
End Sub
Sub vv_Complete
Log("Playing completed")
End Sub
 

vb1992

Well-Known Member
Licensed User
Longtime User
My app got the same message, and I started the video
with a button.

Do you think it's the Video encoding of the mp4?


B4X:
Sub Globals
    Dim vv As VideoView
   Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
   
   Activity.LoadLayout("playmp4")
   vv.Initialize("vv")
    Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
   
    
   
End Sub
Sub vv_Complete
    Log("Playing completed")
End Sub
Sub Button1_Down
 
 vv.LoadVideo(File.DirRootExternal, "give.mp4")
 
   vv.Play
End Sub
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Streaming works, but not the local mp4

B4X:
Sub Button1_Down
 
 'vv.LoadVideo(File.DirRootExternal, "sample.mp4")
 vv.LoadVideo("http","http://videoqube.com/iphone/95.mp4")
   vv.Play
End Sub
 
Upvote 0

metrick

Active Member
Licensed User
Longtime User
I got it to work with
vv.LoadVideo(File.DirRootExternal, "MyFile.mp4")
vv.play

Note:
MyFile.mp4 is recorded with the cell phone.
I don't think is the encoder.
I moved MyFile.mp4 to the program via Files tab and access with
vv.LoadVideo(File.DirInternal, "MyFile.mp4") won't play
vv.LoadVideo(File.DirAssets, "MyFile.mp4") won't play either

I am going to try via WebView method but no time yet.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Playing Video

I got it to work with
vv.LoadVideo(File.DirRootExternal, "MyFile.mp4")
vv.play

Note:
MyFile.mp4 is recorded with the cell phone.
I don't think is the encoder.
I moved MyFile.mp4 to the program via Files tab and access with
vv.LoadVideo(File.DirInternal, "MyFile.mp4") won't play
vv.LoadVideo(File.DirAssets, "MyFile.mp4") won't play either

I am going to try via WebView method but no time yet.

Hello,

You can't play from the assets directory. You can however, include the .mp4 in the assets directory and when your program starts, copy the .mp4 from the assets to File.DirInternal. Once you copy it to DirInternal, the code you had should work. See Example below.

B4X:
Sub Globals
    Dim vv As VideoView
End Sub
Sub Activity_Create(FirstTime As Boolean)
    vv.Initialize("vv")
    Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
    File.Copy(File.DirAssets, "MyFile.mp4", File.DirInternal, "MyFile.mp4")
    vv.LoadVideo(File.DirInternal, "MyFile.mp4")
    vv.Play
End Sub
Sub vv_Complete
    Log("Playing completed")
End Sub

Thanks,

Margret
 
Last edited:
Upvote 0

BarrySumpter

Active Member
Licensed User
Longtime User
Hi all,

Just wondering if there has been any progress on playing a video via http or via local network?

i.e. streaming a video from my localhost or from my pc or from my http address to my android phone?

This is the only way it works.
vv.LoadVideo(File.DirRootExternal, "1.mp4") - DOES work

vv.LoadVideo("http","localhost/1.mp4") - won't work
vv.LoadVideo("http","http://myWebAddress/video_test.mp4") - won't work

these directly above are available via my pc browser.

Perhaps there is something I need to tick on the Android OS?

tia
 
Last edited:
Upvote 0

BarrySumpter

Active Member
Licensed User
Longtime User
Have you tried:
B4X:
vv.LoadVideo("http","http://<YOUR_PC_IP>/video_test.mp4")

woohoo!
vv.LoadVideo("http","http://192.168.1.6/1.mp4")
Works with errors.

1.mp4 is a vid I recorded on my phone using the vv sound and vid recording sample from v4a forum.

Doh!
vv.LoadVideo("http","http://192.168.1.6/video_test.mp4")
errors and WILL NOT play
video_test.mp4 is one I dl'd from the internet.


perhaps someone has something working with video streaming from VLC web interface?
 
Last edited:
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
The code below plays a video from youtube.com without issue. Reading and looking for hours I have found that the url displayed for a video is not the .3gp file but a link to it. I found a way to get the actual link for the video like listed below. With the real url to the direct video file the videoview plays it fine.

Now, if we can get one of the Heavy Weight guys (The Real Programmers) to figure out how to resolve the link to the actual video file of a selected resolution and name we might have something. This is the first video file from youtube I have seen playing!

If you search for this video your browser returns and shows this url when the video is playing:

http://www.youtube.com/watch?v=CEQouX5U0fc

However, this is not the link to the video file. The second link below is the link to the same video file on the youtube server.

B4X:
'this link will not work
vv.LoadVideo("http", "http://www.youtube.com/watch?v=CEQouX5U0fc")


'this link will
vv.LoadVideo("http", "rtsp://v5.cache2.c.youtube.com/CjgLENy73wIaLwn30VR-uShECBMYDSANFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNghoOO2vHq2M1PDA==/0/0/0/video.3gp")
 
Last edited:
Upvote 0

dunski

Member
Licensed User
Longtime User
If you search for this video your browser returns and shows this url when the video is playing:

How Large is the Universe? - YouTube

However, this is not the link to the video file. The second link below is the link to the same video file on the youtube server.

B4X:
'this link will not work
vv.LoadVideo("http", "http://www.youtube.com/watch?v=CEQouX5U0fc")


'this link will
vv.LoadVideo("http", "rtsp://v5.cache2.c.youtube.com/CjgLENy73wIaLwn30VR-uShECBMYDSANFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNghoOO2vHq2M1PDA==/0/0/0/video.3gp")

Hi Margret,
Iv'e been trying to get this video view working all day then I saw this post and you're right it works. Thank You! I tried out this second URL also in my app and was delighted to see something at last playing on my phone.
How do you find out the real URL please?
Dunski
 
Upvote 0

adamioan

Member
Licensed User
Longtime User
Hi Margret,
Iv'e been trying to get this video view working all day then I saw this post and you're right it works. Thank You! I tried out this second URL also in my app and was delighted to see something at last playing on my phone.
How do you find out the real URL please?
Dunski
Query using YouTube API
B4X:
https://gdata.youtube.com/feeds/api/videos/VIDEO_ID?v=2

In Margret example the API url is
B4X:
https://gdata.youtube.com/feeds/api/videos/CEQouX5U0fc?v=2
 
Upvote 0

petr4ppc

Well-Known Member
Licensed User
Longtime User
Where I must the file: video.mp4 ?

Please very much, I need help.

I have read all in this part of forum about this style of mp4 playing.

But I dont know, where I must copy the file video.mp4?
In which folder?
I have project set in this folder:
c:\videoplayer\
I am adding it via IDE

in this folder are this folders: FILES and OBJECTS
and in this folders are are many folders...
The file after adding in IDE is in folder FILES

I am using virtual device first, then I copy project to android device...
But in virtual device and android device is the same information: FILE IS NOT POSSIBLE TO PLAY

please very much, help me please...what i am doing wrong?
Thank you very much
best regards
petr


Notes:
I am trying it one day and one night....but nothing
I am adding file which I take from camera of android device, video.mp4 (200KB) - i am adding file via the file manager in the IDE.
It take cca 40 second to compile project
After this I have message, that this video is not possible to play
I am trying : play after click on button, play after 5 second, play when application is open
I dont know what I must try, please help me


i am trying this:
' vv.Initialize("vv")
' Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
' vv.LoadVideo(File.DirRootExternal, "video.mp4")
' vv.Play

2)and this:
vv.Initialize("vv")
Activity.AddView(vv, 10dip, 10dip, 250dip, 250dip)
File.Copy(File.DirAssets, "video.mp4", File.DirInternal, "video.mp4")
vv.LoadVideo(File.DirInternal, "video.mp4")
vv.Play
 
Last edited:
Upvote 0

jruiz1998

Member
Licensed User
Longtime User
Video from Azure Storage

I used:
vv.LoadVideo("/storage/extSdCard/", "videos_barcode_2/video1.mp4")
vv.Play
And worked very well.

When I changed to work with Azure Storage... Did not work.
vv.LoadVideo("http", "http://appl.blob.core.windows.net/videos/video1.mp4")
vv.Play

I added "<uses-permission android:name="android.permission.INTERNET"/>" to Manifest Editor (AddManifestText).
I used the URL directly from browser and worked fine.

¿What is it wrong?

Thanks
Jorge
 
Upvote 0
Top