Videoview, Cannot play video

dunski

Member
Licensed User
Longtime User
When I try to use videoview with the folowing code I get this error message "Cannot play video", "Sorry, this video cannot be played"

B4X:
Dim vv As VideoView
vv.Initialize("vv")
Activity.AddView(vv, 0, 0, 100%x, 100%y)
vv.LoadVideo("http","http://youtu.be/-FFlpxn-Twc")
vv.Play

I can play this youtube video on my phone no problem if I click on it from the browser. I also have the following in my manifest editor...
AddPermission(android.permission.INTERNET)
:sign0163:
 
Last edited:

dunski

Member
Licensed User
Longtime User
Problem Solved

Just in case this is ever of use to anyone....
I found that if you want to play a video from youtube
you need to download it using a youtube downloader. Then convert it from .flv to .3gp using guess what... some converter. You can get lots off the net.
Then upload the file to your own server which is what I did. I presume it would work on the sd card just as good also as long as its a .3gp.

One last thing do not have any spaces in the URL name.

example:
"http://myserver.com/my file.3gp" This will not work.

Make sure it is "http://myserver.com/myfile.3gp"

Dunski
 
Upvote 0

BowTieNeck

Member
Licensed User
Longtime User
Sorry, this video cannot be played

I'm also having trouble with VideoView. I'm trying to view a locally stored video file that gets copied from the assets folder to external (or internal if there's not enough space).
The file started out as a .mov. I've tried converting it to wmv, mp4, 3gp and they all get rejected with the above message. They all play ok in Media Monkey, QuickTime or Windows Media Player.
So it must be my code. I've added the 2 second wait between load and play as was suggested elsewhere, to no avail.
I've attached a stripped down version of my app to illustrate the problem, hoping that someone can tell me where I'm going wrong.
Thanks in advance.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Works fine here.

VideoView can only play files from the external storage.
I've changed this code:
B4X:
Sub CopyFileFromAssets (FileName As String) As String
   Dim TargetDir As String = File.DirRootExternal
   If File.Exists(TargetDir, FileName) = False Then
      File.Copy(File.DirAssets, FileName, TargetDir, FileName)
   End If
   Return TargetDir
End Sub

 
Upvote 0

BowTieNeck

Member
Licensed User
Longtime User
I didn't realise the file had to go in the External folder. I put it into the Internal folder because the SD card had filled up. I've now made some space.
Thanks.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…