Has anyone been able to successfully play a video using Android Things on a Raspberry Pi? If so was there anything special you had to do to get it to work? If not does any one know why it isn't working?
I made a simple video player that plays a local video from disk. The app runs fine on a phone but I get an error dialog on the Pi saying "Can't play this video".
One Thing I have already ran into but I think I solved was there are no content providers in Android Things, so instead of using a uri for the video source I gave it a file directly like so.
EDIT: Code edit
VideoView videoPanel;
.
.
.
videoPanel.SetVideoURI(Android.Net.Uri.FromFile(new Java.IO.File("/sdcard/Movies/videoFile.mp4")));
I was using 0.5.1-devpreview with raspberry pi 3, and tried to use exoplayer to play mp4. Audio works but not video (just black screen). Same result for youtube iframe sdk (black screen with only audio playing).
I was able to get it to work for my project using setVideoPath instead of SetVideoURI. So your code would be
File file = new Java.IO.File("/sdcard/Movies/videoFile.mp4");
videoPanel.setVideoPath(file.getAbsolutePath());
Try adding this
android:hardwareAccelerated="true"
to your activity in the manifest.
Related
I have yet to find a way to play an youtube streaming video in Android Tv using leanback library. Any suggestions or pointers are greatly appreciated.
I noticed that it will play mp4 files but not live streams.
here is code that works:
movie1.setVideoUrl("http://commondatastorage.googleapis.com/android-tv/Sample%20videos/Demo%20Slam/Google%20Demo%20Slam_%2020ft%20Search.mp4");
mItems.add(movie1);
That works just fine.
But if I change it to a streaming video like the following:
movie1.setVideoUrl("http//livestreaming2.itworkscdn.net/squranlive/squran_360p");
mItems.add(movie1);
it will not show the video on the screen. it is blank and then crashes.
And when I use this code:
movie1.setVideoUrl("http://www.youtube.com/embed/VopbGPJVkzM");
mItems.add(movie1);
it just crashes
Also - i have to connect it to my android 5.0.1 tablet and android studio does not show the logcat output in Android Studio. What do I need to turn on as an option in Android Studio for the logcat output to be seen (from the device run of the application)?
Thanks everyone.
ironmantis7x
I found that if i make a YT intent and then call that intent as an activity, it works.
I am using the following code to stream the videos from my server on android phone:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(videoUrl)); // When I hit this URL in web browser on my PC, it works
startActivity(i);
When I run the code, it asks me to select a player. When I select a player, that player opens up and then nothing happens. I've even tried waiting for minutes, but the video never starts.
My question is, is it really as simple to just put the video on my webserver and on android run the above code to get that video streaming?
Do I need to make any changes on my server? Can anyone please help me with this? I cannot figure out if the problem is with my sever or client side.
It was the problem of VLC player that I was using on my Android Phone for testing. I downloaded the MX Player and tried it with that. Everything is working fine now :-)
That means not every video player on Google Play is mature enough to take a URL and start streaming the video. For that you need a good video player that supports this feature.
I've searched all over for a solution to this (including SO), however still haven't found a solution.
I need to have a simple video playback in my app. It's a bit less straightforward than a simple window with a video. Simplified, I have two layouts on my screen, one containing some other stuff and the other is to have the video window. There's also a button to switch between the two. This all works just fine, after I figured out that the videoview cannot be present on a view with visibility 'gone' - therefore I'm adding/removing it to/from container layout when needed.
However, I have the problem with the actual video playback. When I try to activate it, I get the dreaded error Sorry, this video cannot be played. One of the questions here on SO is discussing video formats (Android -- Can't play any videos (mp4/mov/3gp/etc.)?) - however I already have what seems to be the correct format, with 320px width and everything else. One of the answers on that thread mentions that videos from here "definitely work". I tried a couple from there - but I got another common beast: Sorry, this video is not valid for streaming to this device.
Please note that I'm testing on an actual device, as video playback is not working in the emulator. Also note that the solution must work on Android 1.6 and above (client's requirement). The device I'm testing on is LG GT540 Optimus with Android 2.1 (at present I don't have any other devices available).
From what I figured out, if I don't use qt-faststart on the videos, I get error Sorry, this video is not valid for streaming to this device. If I do use qt-faststart, then I get Sorry, this video cannot be played.
Here's my code for the playback:
VideoViewer videoPlayer = new VideoViewer(this);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoPlayer);
videoPlayer.setMediaController(mediaController);
videoPlayer.setVideoURI(Uri.parse(object.getVideoURL()));
LinearLayout container = (LinearLayout)ObjectInfo.this.findViewById(R.id.VideoContainer);
container.setVisibility(VISIBLE);
container.addView(videoPlayer, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
videoPlayer.requestFocus();
videoPlayer.start();
Now, the video I'm trying to play is to be progressive-downloaded from HTTP: object.getVideoURL() returns http://www.ooklnet.com/files/381/381489/video.mp4
Can anybody please help me sort this out? This is the last thing I need to complete before the whole app is ready.
Many thanks!
Edit: I tried using MediaPlayer - but got even worse results than with VideoView, so went back to VideoView. Now, in simulator, I get a black screen with controls hovering over it and the sound of the video is playing fine, also the progress is adjusting as the playback continues. However on my actual device, I'm still getting Sorry, this video cannot be played. error
Turned out the problem was with the format of the videos (specifically, the parameters I used with ffmpeg to create the MP4 videos). I ensured that the videos are baseline H.264 - and everything worked properly. See this question for more details.
Maybe you need to change the way you set up your MediaPlayer. I just plugged the url of your sample video into the apidemos example and it worked just fine.
See:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html
Hope that helps.
I'm trying to stream .m3u8 file using media player for Android. But it seems the media player failed to fetch the playlist:
Error log:
08-28 13:40:48.358: ERROR/LiveSession(8804): unable to fetch master playlist 'http://192.168.0.3:49152/live-streaming/192.168.0.5/6344.m3u8'.
The most frustrated things so far is I did this once and it worked fine, Once I tried for second time, blank screen just appeared.
http://vov.io/vitamio/ This library supports m3u8. see if it works a little better.
Maybe a long shot, but have you tried httplive://192.168.0.3:49152/live-streaming/192.168.0.5/6344.m3u8 ?
Using that in html5 video elements works in Android 2.3.5 for me.
I would suggest ExoMedia, a striped down easier-to-use version of Google's own ExoPlayer. Streams m3u8 well, easy as:
emVideoView.setVideoURI(Uri.parse("https://somewebsite.com/somepath/somelink.m3u8"));
I've coded up apps using VideoView and MediaPlayer and both had the same behavior. I'm currently using the code example here. The problem I'm having is that the video doesn't play back continuously. The slider in the MediaController is moving but the picture doesn't change. If I manually drag the slider the picture will change like it should.
I'm using an mp4 file loaded from the sdcard with a SDK 2.3.1 emulator device.
Any help is appreciated.
You usually cannot test video playback applications on the Android emulator, as it is too slow, except on very powerful host PCs. Please test video playback applications on an Android device.