当前位置: 首页>>代码示例>>Java>>正文


Java MediaController.setMediaPlayer方法代码示例

本文整理汇总了Java中android.widget.MediaController.setMediaPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java MediaController.setMediaPlayer方法的具体用法?Java MediaController.setMediaPlayer怎么用?Java MediaController.setMediaPlayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.MediaController的用法示例。


在下文中一共展示了MediaController.setMediaPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPrepared

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
    public void onPrepared(MediaPlayer mp) {
        if(mHasVideo) {
            mediaPlayer.start();
            mediaPlayer.setVolume(0,0);
            setVideoSize();
            vidSurface.bringToFront();
            vidSurface.requestFocus();
            MediaController mController = new MediaController(context);
            mController.setMediaPlayer(this);
            mController.setAnchorView(vidSurface);

//        mController.show(0);
            vidSurface.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
        }
    }
 
开发者ID:pawelpaszki,项目名称:youtube_background_android,代码行数:22,代码来源:DownloadedFragment.java

示例2: onCreate

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_side_by_side);
    //Utils.setActionBarSubtitleEllipsizeMiddle(this);

    mAndroidVideoView = (android.widget.VideoView) findViewById(R.id.androidvv);
    mItecVideoView = (VideoView) findViewById(R.id.itecvv);

    mMediaPlayerControl = new MediaPlayerMultiControl(mAndroidVideoView, mItecVideoView);
    mMediaController = new MediaController(this);
    mMediaController.setAnchorView(findViewById(R.id.container));
    mMediaController.setMediaPlayer(mMediaPlayerControl);

    mPath = getIntent().getStringExtra("play");
    mTitle = getIntent().getStringExtra("play");
    if(StringUtils.isHttp(mPath)) {
        if (!checkWifi()) {
            ToastUtil.showMessage(getString(R.string.network_waste));
            wifiStateDlg();
            return;
        }
    }

    loadVideo();
}
 
开发者ID:zhangjingpu,项目名称:youkes_vr,代码行数:27,代码来源:SideBySideVideoPlayActivity.java

示例3: onCreate

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_videoview);
    Utils.setActionBarSubtitleEllipsizeMiddle(this);

    mVideoView = (VideoView) findViewById(R.id.vv);
    mProgress = (ProgressBar) findViewById(R.id.progress);

    mMediaPlayerControl = mVideoView; //new MediaPlayerDummyControl();
    mMediaController = new MediaController(this);
    mMediaController.setAnchorView(findViewById(R.id.container));
    mMediaController.setMediaPlayer(mMediaPlayerControl);
    mMediaController.setEnabled(false);

    mProgress.setVisibility(View.VISIBLE);

    // Init video playback state (will eventually be overwritten by saved instance state)
    mVideoUri = getIntent().getData();
    mVideoPosition = 0;
    mVideoPlaybackSpeed = 1;
    mVideoPlaying = false;
}
 
开发者ID:protyposis,项目名称:MediaPlayer-Extended,代码行数:24,代码来源:VideoViewActivity.java

示例4: play

import android.widget.MediaController; //导入方法依赖的package包/类
private void play() {
	mProgressBar.setVisibility(View.VISIBLE);
	Uri videoUri = Uri.parse(mVideoUrl);
	try {
		mVideoView.setOnCompletionListener(this);
		mVideoView.setOnPreparedListener(this);
		mVideoView.setOnErrorListener(this);
		mVideoView.setVideoURI(videoUri);
		mMediaController = new MediaController(this);
		mMediaController.setAnchorView(mVideoView);
		mMediaController.setMediaPlayer(mVideoView);
		if (!mControls) {
			mMediaController.setVisibility(View.GONE);
		}
		mVideoView.setMediaController(mMediaController);
	} catch (Throwable t) {
		Log.d(TAG, t.toString());
	}
}
 
开发者ID:nchutchind,项目名称:cordova-plugin-streaming-media,代码行数:20,代码来源:SimpleVideoStream.java

示例5: initializeVideoViewControls

import android.widget.MediaController; //导入方法依赖的package包/类
private void initializeVideoViewControls(@NonNull VideoView videoView) {
  MediaController mediaController = new MediaController(getContext());
  mediaController.setAnchorView(videoView);
  mediaController.setMediaPlayer(videoView);

  videoView.setMediaController(mediaController);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:8,代码来源:VideoPlayer.java

示例6: createVideoView

import android.widget.MediaController; //导入方法依赖的package包/类
private synchronized void createVideoView() {
  if(mVideoView != null){
    return;
  }
  Context context = getContext();
  WXVideoView video = new WXVideoView(context);
  FrameLayout.LayoutParams videoLayoutParams =
      new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.MATCH_PARENT);
  videoLayoutParams.gravity = Gravity.CENTER;
  video.setLayoutParams(videoLayoutParams);
  addView(video, 0);//first child
  video.setOnErrorListener(mOnErrorListener);
  video.setOnPreparedListener(mOnPreparedListener);
  video.setOnCompletionListener(mOnCompletionListener);
  video.setOnVideoPauseListener(mVideoPlayListener);
  MediaController controller = new MediaController(context);
  controller.setAnchorView(this);
  video.setMediaController(controller);
  controller.setMediaPlayer(video);

  mMediaController = controller;
  mVideoView = video;

  if(mUri != null) {
    setVideoURI(mUri);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:29,代码来源:WXVideoView.java

示例7: initMediaController

import android.widget.MediaController; //导入方法依赖的package包/类
/**
 * Creates a media controller and attaches it to the activity.
 * This method is for activities that contain a video player.
 * @param mediaPlayerControl the control interface, e.g. a video view
 */
public void initMediaController(MediaController.MediaPlayerControl mediaPlayerControl) {
    mMediaController = new MediaController(this);
    mMediaController.setAnchorView(findViewById(R.id.container));
    mMediaController.setMediaPlayer(mediaPlayerControl);
    mMediaController.setEnabled(false);
}
 
开发者ID:protyposis,项目名称:Spectaculum,代码行数:12,代码来源:SpectaculumDemoBaseActivity.java

示例8: onCreate

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    View root = findViewById(R.id.root);
    mediaController = new MediaController(this);

    //overscan safe on 1980 * 1080 TV
    mediaController.setPadding(48, 27, 48, 27);
    mediaController.setAnchorView(root);
    shutterView = findViewById(R.id.shutter);
    surfaceView = (VideoSurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);

    SampleSource sampleSource =
            new FrameworkSampleSource(this, Uri.parse(url), /* headers */ null, RENDERER_COUNT);

    // Build the track renderers
    videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);
    TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

    // Setup the player
    player = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 1000, 5000);
    player.addListener(this);
    // Build the player controls
    mediaController.setMediaPlayer(new PlayerControl(player));
    mediaController.setEnabled(true);
    player.prepare(videoRenderer, audioRenderer);
}
 
开发者ID:googlecodelabs,项目名称:android-tv-leanback,代码行数:31,代码来源:PlayerActivity.java

示例9: setDefaultControlsEnabled

import android.widget.MediaController; //导入方法依赖的package包/类
public void setDefaultControlsEnabled(boolean enabled) {
    if (enabled) {
        mediaController = new MediaController(getContext());
        mediaController.setAnchorView(videoFrame);
        mediaController.setMediaPlayer(okPlayer.getPlayerControl());
        mediaController.setEnabled(true);
    }

    CustomTouchListener listener = new CustomTouchListener(getContext());
    setOnTouchListener(enabled ? listener : null);
}
 
开发者ID:succlz123,项目名称:OkPlayer,代码行数:12,代码来源:OkVideoView.java

示例10: onCreate

import android.widget.MediaController; //导入方法依赖的package包/类
/**
 * 
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_main);
    
    mVideoLayout1 = (RelativeLayout) findViewById(R.id.video_layout1);
    mVideoLayout2 = (RelativeLayout) findViewById(R.id.video_layout2);
    
    mPreview = (SurfaceView) findViewById(R.id.surface);
    holder = mPreview.getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    
    video1=(VideoView)findViewById(R.id.video1);  
    mediaco=new MediaController(this);  
    //Uri uri = Uri.parse("http://static.smartisanos.cn/common/video/smartisant1.mp4");   
   // video1.setVideoURI(uri);  
   
    File file=new File("/mnt/sdcard/smartisant1.mp4");  
    if(file.exists()){  
        //VideoView与MediaController进行关联  
        video1.setVideoPath(file.getAbsolutePath());  
        video1.setMediaController(mediaco);  
        mediaco.setMediaPlayer(video1);  
        //让VideiView获取焦点  
        video1.requestFocus(); 
    }   
}
 
开发者ID:zxy198717,项目名称:TwoVideoPlayerInOneScreenDemo,代码行数:33,代码来源:MainActivity.java

示例11: onCreateDialog

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	View v = getActivity().getLayoutInflater()
			.inflate(R.layout.fragment_play_video, null);
	
	mVideoView = (VideoView)v.findViewById(R.id.hellomoon_playVideoView);
	Uri resourceUri = Uri.parse("android.resource://org.mazhuang.android.hellomoon/" + R.raw.vid_20150110_211545);
	//File file = new File("/sdcard/Download/vid_20150110_211545.mp4");
	mMediaController = new MediaController(getActivity());
	mVideoView.setMediaController(mMediaController);
	mMediaController.setMediaPlayer(mVideoView);
	//mVideoView.setVideoPath(file.getAbsolutePath());
	mVideoView.setVideoURI(resourceUri);
	mVideoView.requestFocus();
	mVideoView.start();
	
	mVideoView.setOnCompletionListener(new OnCompletionListener() {
		
		@Override
		public void onCompletion(MediaPlayer mp) {
			PlayVideoFragment.this.dismiss();
		}
	});
			
	return new AlertDialog.Builder(getActivity())
		.setView(v)
		.create();
}
 
开发者ID:mzlogin,项目名称:AndroidPractices,代码行数:29,代码来源:PlayVideoFragment.java

示例12: onServiceConnected

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName className, IBinder serviceBinder) {
    service = ((PlayServiceBinder) serviceBinder).getService();
    // Attach the listeners and provide our surface
    service.setVideoSurfaceProvider(DefaultFullscreenVideoActivity.this);
    service.addPlayServiceListener(DefaultFullscreenVideoActivity.this);

    // Create the media controller to show when the surface is touched
    controller = new MediaController(DefaultFullscreenVideoActivity.this, service.canSeekForward()) {

        @Override
        public boolean dispatchKeyEvent(KeyEvent event) {
            if (event != null && KeyEvent.KEYCODE_BACK == event.getKeyCode() &&
                    KeyEvent.ACTION_DOWN == event.getAction() && event.getRepeatCount() == 0) {
                // Override the default behaviour, i.e. close on first back command
                // instead of just hiding the media controller
                finish();

                return true;
            } else
                return super.dispatchKeyEvent(event);
        }
    };
    controller.setMediaPlayer(service);
    controller.setAnchorView(findViewById(R.id.controller_anchor));

    attachPrevNextListeners();
}
 
开发者ID:salema,项目名称:Podcatcher-Deluxe-Android-Studio,代码行数:29,代码来源:DefaultFullscreenVideoActivity.java

示例13: onCreate

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_video);

    final ProgressBar progressBar = findViewById(R.id.video_progress);
    VideoView videoView = findViewById(R.id.video_player);

    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setTitle(null);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
    }

    String url = getIntent().getStringExtra("url");

    videoView.setVideoPath(url);
    MediaController controller = new MediaController(this);
    controller.setMediaPlayer(videoView);
    videoView.setMediaController(controller);
    videoView.requestFocus();
    videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            progressBar.setVisibility(View.GONE);
            mp.setLooping(true);
            hideToolbarAfterDelay();
        }
    });
    videoView.start();

    videoView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                handler.removeCallbacksAndMessages(null);
                toolbar.animate().cancel();
                toolbar.setAlpha(1);
                toolbar.setVisibility(View.VISIBLE);
                hideToolbarAfterDelay();
            }
            return false;
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(Color.BLACK);
    }
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:53,代码来源:ViewVideoActivity.java

示例14: onAccountSet

import android.widget.MediaController; //导入方法依赖的package包/类
@Override
protected void onAccountSet(boolean stateWasRecovered) {
    super.onAccountSet(stateWasRecovered);
    if (getAccount() != null) {
        OCFile file = getFile();
        /// Validate handled file  (first image to preview)
        if (file == null) {
            throw new IllegalStateException("Instanced with a NULL OCFile");
        }
        if (!file.isVideo()) {
            throw new IllegalArgumentException("Non-video file passed as argument");
        }
        file = getStorageManager().getFileById(file.getFileId());
        if (file != null) {
            if (file.isDown()) {
                mVideoPlayer.setVideoURI(file.getStorageUri());

            } else {
                // not working yet
                String url;
                try {
                    url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
                    mVideoPlayer.setVideoURI(Uri.parse(url));
                } catch (AccountNotFoundException e) {
                    onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
                }
            }

            // create and prepare control panel for the user
            mMediaController = new MediaController(this);
            mMediaController.setMediaPlayer(mVideoPlayer);
            mMediaController.setAnchorView(mVideoPlayer);
            mVideoPlayer.setMediaController(mMediaController);

        } else {
            finish();
        }
    } else {
        finish();
    }
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:42,代码来源:PreviewVideoActivity.java

示例15: setupMediaController

import android.widget.MediaController; //导入方法依赖的package包/类
protected void setupMediaController() {
	mMediaController = new MediaController( this );
	mMediaController.setEnabled(true);
	mMediaController.show();
	mMediaController.setMediaPlayer( mVideoView );
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:7,代码来源:VideoPlayerActivity.java


注:本文中的android.widget.MediaController.setMediaPlayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。