Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Context, Token) in instantiating MediaController

I am trying to add a mediaController in my VideoView. I am trying to follow the tutorial in this site.

However, I am having an error in my class in this line.

MediaController mediaController = new MediaController(this);

The error says,

MediaController (Context, Token) in MediaController cannot be applied to (MainActivity)

What is the Token parameter? Its been a while since I have coded in Native Android and I think I missed some necessary details and changes.

EDIT I was looking in a different tutorial, the one in the link, is Made in Android Studio. My Mistake.

My Class

public class MainActivity extends ActionBarActivity {
public VideoView videoOne;
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    videoOne = (VideoView) findViewById(R.id.videoView);
    videoOne.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video1));
    videoOne.start();

    MediaController mediaController = new MediaController(this);
    mediaController.setAnchorView(videoOne);
    videoOne.setMediaController(mediaController);

    videoOne.setOnPreparedListener(new MediaPlayer.OnPreparedListener()  {
        @Override
        public void onPrepared(MediaPlayer mp) {
            Log.i("Video Duration", "Duration = " + videoOne.getDuration());
        }
    });
    videoOne.setMediaController(mediaController);

}
like image 282
Jeongbebs Avatar asked Feb 12 '15 05:02

Jeongbebs


People also ask

Is it possible to read access token from httpcontext in core?

That’s all, Finally, we found it is very simple to read access token from HttpContext in .NET Core. Happy Coding!! Do you have any comments or ideas or any better suggestions to share?

What is access token in JWT?

Access tokens enable clients to securely call protected web APIs and help perform authentication and authorization while providing access to requested resource. IN the below example we have used “”access_token” to access JWT Bearer token.

What is an access token?

The below piece of code is from the same sample which we learned in Access tokens enable clients to securely call protected web APIs and help perform authentication and authorization while providing access to requested resource. IN the below example we have used “”access_token” to access JWT Bearer token.

Can I use dbcontext with a dependency injection container?

Please note that the use of DbContext using a dependency injection container is recommended. This ensures DbContext is created as per request by the API pipeline and disposed of based on lifetime management used while registering it. Please configure your DBContext as below in ASP.NET Core API as below,


2 Answers

The error is pretty straightforward. Make sure you are importing the correct MediaController. For your purpose you need this import:

import android.widget.MediaController;

The above class has the constructor you are looking for. The link:

http://developer.android.com/reference/android/widget/MediaController.html#MediaController(android.content.Context)

You might be using the one below:

 import android.media.session.MediaController;

Hope this helps

like image 199
user2511882 Avatar answered Sep 17 '22 11:09

user2511882


this one solve my 'this' issue

import import android.widget.MediaController;
like image 31
Khan Avatar answered Sep 20 '22 11:09

Khan