public class MyPlayer extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(akki.player.R.layout.main);
boolean flashInstalled = false;
try {
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.adobe.flashplayer", 0);
if (ai != null)
flashInstalled = true;
} catch (NameNotFoundException e) {
flashInstalled = false;
}
if(flashInstalled){
WebView browser=(WebView) findViewById(akki.player.R.id.webView1);
//
browser.getSettings().setJavaScriptEnabled(true);
;
browser.getSettings().getPluginsEnabled();
browser.getSettings().setAllowFileAccess(true);
browser.getSettings().setAppCacheEnabled(false);
browser.loadUrl("http://sound30.mp3pk.com/indian/dabangg2/[Songs.PK]%2004%20-%20Saanson%20Ne%20-%20Dabangg%202.mp3");
Toast.makeText(this, "Flash Player installed ....", 1).show();
}
else
{
Toast.makeText(this, "Install Flash Player First ..", 1).show();
}
}
this is my code to play a song from website. but it says webpage not available.
what is the possible error.?
thanx in advance.
i have a player.html file linking a player to the website as well.
the code is working fine as it asks to install flash player as mentioned in the code but when i launch the application it just not displays the webpage. Instead it says webpage not available.
I think that you should download it and play it with Mediaplayer. I see that you try to use Flash player, but Flash player isnt unsupported:
http://arstechnica.com/gadgets/2012/06/no-flash-for-android-4-1-no-new-installs-after-august-15/
The main thing is that you putting mp3 file in webview. You can change your link to http://www.musikmaza.com/2012/11/dabangg-2-2012-latest-hindi-mp3-songs.html . After changing link check that page is showing or not.
Either if you want to play mp3 files then you need a downloadManager for downloading mp3 file and then MediaPlayer for playing that file.
Related
I have a new app and I'm trying to implement it to "Call to Action" facebook page button, but I have no idea what I shall write in the "App link" text box.
They put an example link of: example://location/123456
But I have no idea what it's refering to or what's the App Link of my app.
Tried to find anything about it on the Internet but couldn't find any helpful solution since I have no app links in my app (no products etc)
My goal is that when the user clicks on Facebook "Use App", it will redirect him to the app or the google play store app page if it's not installed..
I'm not talking about open app in my app, im talking about open my app in my facebook page
You can use the next code from the wiki:
/** Open another app.
* #param context current Context, like Activity, App, or Service
* #param packageName the full package name of the app to open
* #return true if likely successful, false if unsuccessful
*/
public static boolean openApp(Context context, String packageName) {
PackageManager manager = context.getPackageManager();
try {
Intent i = manager.getLaunchIntentForPackage(packageName);
if (i == null) {
return false;
//throw new PackageManager.NameNotFoundException();
}
i.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(i);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
Example usage:
openApp(this, "com.google.android.maps.mytracks");
You can read it from here
To post a message in FB, see the next post, maybe it will be useful How to open the Facebook Write Post with some pre defined text and image
You should use Try/Catch. if user have Facebook app, fb://page/12345 link will open in app. Else, Catch code will run.
#Override
public void onClick(View v) {
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("fb://page/12345"))); //12345 is Facebook page number
} catch (Exception e) {
//open play link in browser
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://play.google.com/etc")));
}
}
I wana to develop android app that will play rtsp link from local server, but the tablet screen goes blank.... showing nothing
I had tried both VideoView and MediaPlayer classes.
Work well on youtube rtsp links with .3gp extension but not working on the above URL
Below is my code
public class WifiManagerActivity extends Activity {
private WifiManager customWifiManager;
private VideoView mu;
private String path;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
wifiSettings();
}
private void wifiSettings() {
mu = (VideoView) findViewById(R.id.ttl);
TextView notify = (TextView) findViewById(R.id.wifi_state);
customWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if(customWifiManager.isWifiEnabled()){
Toast.makeText(this, "Your wifi is On now enjoy " +
"live streaming", Toast.LENGTH_SHORT).show();
notify.setTextColor(Color.GREEN);
showVideo();
}else{
Toast.makeText(this, "Turn your Wifi On", Toast.LENGTH_SHORT).show();
customWifiManager.setWifiEnabled(true);
//two second wait here
showVideo();
}
}
private void showVideo() {
Authenticator.setDefault(new MyAuthenticater());
String path = "rtsp://192.168.1.155:554/3g";
mu.setVideoURI(Uri.parse(path));
mu.setMediaController(new MediaController(this));
mu.requestFocus();
mu.start();
}
}
There are multiple factors that can affect whether your stream is playing correctly or not:
check whether your stream is valid and playable (using for example separate instance of VLC)
if that works check logcat for any errors/warnings related to either RTSP connection or video stream itself. Look for tags like: MediaPlayer, ARTSPConnection, MyHandler, ASessionDescription, ACodec.
That should get you started.
The PDF content can be of online as well as offline mode, I need to show pdf in my own customized layout so, Intent can't be used. Any suggestion will be appreciated. thank you.
Yes we are able to show pdf content onLine with the help of google doc api Here i am given code for using it. for ON Line Mode
public class ReaderActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView webView=(WebView)this.findViewById(R.id.WebView01);
Intent intent = new Intent(Intent.ACTION_VIEW);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setPluginsEnabled(true);
webView.loadUrl("https://docs.google.com/viewer?url=http%3A%2F%2Fwww.eli.sdsu.edu%2Fcourses%2Ffall09%2Fcs696%2Fnotes%2FAndroid13Web.pdf");
//intent.setDataAndType(Uri.parse("https://docs.google.com/viewer?url=---------Your URL");
}}
for OFF Line Mode
File file = new File(mRealPath);
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setDataAndType(path, getString(R.string.application_type));
try
{
startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(FirstTab.this,
getString(R.string.no_application_found),
Toast.LENGTH_SHORT).show();
}
Note-:In off line mode first you have download file form server to own local device in sd-card the get path of this document and put it on in the place of path variable then you get answer of your hole question.
In this code you should use your url in the place my url.
I hope this is help.
First of there is no support for pdf in Android so you need to open in some other app like adob or if you want to do it right way then need make the load lib like vudroid and apdfviewer .
apdfviewer is very good but there is no support how to compile source code, actually all lib work with c++ in backend so you need to install the ndk.
Vudroid is slow but you can compile easily.
I hope this will help you.
But
Some phones (like the Nexus One) come with a version of Quickoffice pre-installed so it may be as easy as sending the appropriate Intent once you've saved the file to the SD card.
public class OpenPdf extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.OpenPdfButton);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
}
});
}
}
I found that Internet connectivity mode :- through google doc we can open the pdf.
but in the Internet offline mode:- we need to use Intent and open the pdf file through any one of the pdf viewer application install in the device.
one things we can do in the offline mode is that, instead of opening the option of multiple pdf viewer reader in device and select one application to open pdf file we can open the pdf with the particular application.
I'm a Flash developer by trade, have recently made the jump into Android as the company I work for are moving into apps. I've made a video gallery based on an XML feed, it all works fine until I have to play the movie itself, at which point I get:
Unable to play video. Invalid streaming data.
My gallery items fire up another activity with the .mp4 link as an extra:
public class Video_play extends Activity implements View.OnClickListener {
String vLink;
Uri vid;
VideoView vv;
MediaPlayer mp;
SurfaceHolder holder;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//Hide app title
Bundle extras = getIntent().getExtras();
if (extras != null) {
vLink = extras.getString("video");
vid = Uri.parse(vLink);
}
setContentView(R.layout.vidplay_layout);
vv = (VideoView)findViewById(R.id.vid_fscreen);
Log.i("Video link is: ",vid+"");
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(vv);
vv.setMediaController(mediaController);
vv.setVideoURI(vid);
vv.start();
}
public void onClick(View v) {
}
}
I've been looking all afternoon and I can't find any straightforward advice on what I'm doing wrong. Any help would be absolutely life-saving, thanks in advance.
What version of Android are you testing it on? HTTP progressive streaming for MP4 video was not fully supported until Android 2.2.
For streaming playback on earlier Android versions you can usually work around this by using post-encoding software like MP4Box to add "hint tracks" to the file:
MP4Box -hint <filename>
http://www.videohelp.com/tools/mp4box
I want to play video of mp4 format and size 4-5Mb from server in streaming mode.I am using sdk version 2.3,on emulator it
gives only sound but not any picture.
I also tested it on devices Samsung(android sdk ver 2.1) and LG optimus(android sdk ver 2.2)
and only get "cannot play video:sorry this video is not valid for streaming to this device" message.
I have searched on this but not getting any solution, if anybody have any solution please help me.Thanks in advance.
Here is my code:
public class ShowVideo extends Activity
{
private static ProgressDialog progressDialog;
public String video_url;
private MediaController mediaController;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.videoalbum);
progressDialog = ProgressDialog.show(ShowVideo.this, "", "Buffering video...", true);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4";
try {
final VideoView videoView =(VideoView)findViewById(R.id.video_viewId);
mediaController = new MediaController(ShowVideo.this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse(video_url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.start();
}
});
}catch(Exception e){
progressDialog.dismiss();
System.out.println("Video Play Error :"+e.getMessage());
}
}
You may try these urls (ends with .3gp):
http://daily3gp.com/vids/747.3gp
http://daily3gp/www/vids/juggling_while_on_unicycle.3gp
instead of .mp4 urls:
video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4";
On emulator it is difficult to get video played, because it needs really fast computer. Try this link for emulator. Maybe you can get some discrete video view.
http://commonsware.com/misc/test2.3gp
Also in your real devices this link should work if your implementation is proper.
I assume your video using following link
"http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4
is not proper for safe streaming.
You should hint that video or play other hinted videos. I couldn't find any other solution for playing unhinted videos yet.
This link may help.
getting PVMFErrContentInvalidForProgressivePlayback error while playing mp4 files on samsung devices