當前位置: 首頁>>代碼示例>>Java>>正文


Java OnPreparedListener類代碼示例

本文整理匯總了Java中android.media.MediaPlayer.OnPreparedListener的典型用法代碼示例。如果您正苦於以下問題:Java OnPreparedListener類的具體用法?Java OnPreparedListener怎麽用?Java OnPreparedListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OnPreparedListener類屬於android.media.MediaPlayer包,在下文中一共展示了OnPreparedListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initPlayer

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public static void initPlayer(VideoView videoView, OnPreparedListener onPreparedListener,
                              OnCompletionListener onCompletionListener, OnErrorListener
                                      onErrorListener) {
    if (onPreparedListener != null) {
        videoView.setOnPreparedListener(onPreparedListener);
    }
    if (onCompletionListener != null) {
        videoView.setOnCompletionListener(onCompletionListener);
    }
    if (onErrorListener != null) {
        videoView.setOnErrorListener(onErrorListener);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:14,代碼來源:VideoPlayerManager.java

示例2: onResume

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
@Override
public void onResume() {
    super.onResume();
    // ReceiverをRegister
    IntentFilter mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(VideoConst.SEND_HOSTDP_TO_VIDEOPLAYER);
    registerReceiver(mReceiver, mIntentFilter);

    MediaController mMediaController = new MediaController(this);
    mMediaController.setVisibility(View.GONE);
    mMediaController.setAnchorView(mVideoView);

    mVideoView.setMediaController(mMediaController);
    mVideoView.setKeepScreenOn(true);
    mVideoView.setVideoURI(mUri);
    mVideoView.requestFocus();
    mVideoView.setOnCompletionListener(this);
    mVideoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared(final MediaPlayer mp) {
            mVideoView.start();
            mIsReady = true;
        }
    });
}
 
開發者ID:DeviceConnect,項目名稱:DeviceConnect-Android,代碼行數:26,代碼來源:VideoPlayer.java

示例3: initMediaPlayer

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
private void initMediaPlayer(){
	
	Log.d(TAG, "path: " + videFilePath);
	File videoFile = new File(videFilePath);
       FileInputStream fis;
	try {
		fis = new FileInputStream(videoFile);
		mMediaPlayer.setDataSource(fis.getFD());
           mMediaPlayer.prepareAsync();
           mMediaPlayer.setOnPreparedListener(new OnPreparedListener() {
               @Override
               public void onPrepared(MediaPlayer mp) {
                   cancelWaitDialog();
                   if(autoPlayFlagMP){
                       mMediaPlayer.start();
                       setSurfaceViewScale();
                   }
               }
           });
           mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
	} catch (IOException e) {
		Log.e(TAG,"Problem with input stream!",e);
           videoView.setVisibility(View.GONE);
           errorTextView.setVisibility(View.VISIBLE);
	}
}
 
開發者ID:birdcopy,項目名稱:Android-Birdcopy-Application,代碼行數:27,代碼來源:MediaHolder.java

示例4: play

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public void play(){
		//�������״̬
		player.reset();
		try {
			//����Ҫ���ŵ�����
			player.setDataSource("sdcard/zxmzf.mp3");
//			player.setDataSource("http://192.168.1.100:8080/bzj.mp3");
			//ͬ��׼��
//			player.prepare();
			//�첽׼��
			player.prepareAsync();
			player.setOnPreparedListener(new OnPreparedListener() {
				
				//�첽׼�����ʱ���˷�������
				@Override
				public void onPrepared(MediaPlayer mp) {
					player.start();
					addTimer();
				}
			});
//			player.start();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
	}
 
開發者ID:DuGuQiuBai,項目名稱:Android-Basics-Codes,代碼行數:27,代碼來源:MusicService.java

示例5: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public void playVideo(String video, boolean loop) {
		if(!isPlaying){
			if (loop) {
				videoView.setOnPreparedListener(new OnPreparedListener() {
					@Override
					public void onPrepared(MediaPlayer mp) {
						mp.setLooping(true);
					}
				});
			}
			try {
				Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
				if (videoUri == null) {
					if(MainActivity.online){videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());}
				}
				videoView.setVideoURI(videoUri);
				videoView.start();
			} catch (Exception exception) {
				Log.wtf(exception.toString(), exception);
			}
			isPlaying = true;//to Play this video only once.
		}
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:24,代碼來源:ChatActivity.java

示例6: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("null videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:24,代碼來源:AvatarTestActivity.java

示例7: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public void playVideo(String video, boolean loop) {
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:21,代碼來源:AvatarMediaActivity.java

示例8: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public void playVideo(String video, boolean loop) {
	System.out.println("playVideo:" + video);
	if (loop) {
		videoView.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mp.setLooping(true);
			}
		});
	}
	try {
		Uri videoUri = HttpGetVideoAction.fetchVideo(this, video);
		System.out.println("videoUri:" + videoUri);
		if (videoUri == null) {
			videoUri = Uri.parse(MainActivity.connection.fetchImage(video).toURI().toString());
			System.out.println("videoUri:" + videoUri);
		}
		videoView.setVideoURI(videoUri);
		videoView.start();
	} catch (Exception exception) {
		Log.wtf(exception.toString(), exception);
	}
}
 
開發者ID:BotLibre,項目名稱:BotLibre,代碼行數:24,代碼來源:AvatarTestActivity.java

示例9: init

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
private void init(TVASTPlayer player) {
    super.setOnCompletionListener(this);
    super.setOnErrorListener(this);

    this.mPlayer = player;

    OnPreparedListener preparedListener = new OnPreparedListener() {
        @Override
        public void onPrepared(final MediaPlayer mp) {
            for (TVASTAdPlayerListener callback : callbacks) {
                callback.onVideoPlay(mPlayer);
            }
        }
    };
    setOnPreparedListener(preparedListener);
}
 
開發者ID:SnakkAds,項目名稱:snakk-ads-android-sdk,代碼行數:17,代碼來源:TVASTTrackingVideoView.java

示例10: onPostExecute

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
protected void onPostExecute(Integer msec) {
    videoView.seekTo(msec);

    try {
        Thread.sleep(pause*1000);  // this second is added to the startVideoTime
        videoView.start();
    } catch (InterruptedException e) {
        Logga.e(e.toString());
    }

    // if still experiencing delay, implement onSeekCompleteListener.

    videoView.setOnPreparedListener(new OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
}
 
開發者ID:ramuta,項目名稱:android-video-sync,代碼行數:20,代碼來源:VideoActivity.java

示例11: prepare

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
private void prepare(String fileName, boolean looping) {
	Modules.LOG.info(TAG, "Preparing: " + fileName);
	try {
		mediaPlayer.reset();
		mediaPlayer.setLooping(looping);
		mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mp) {
				mediaPlayer.start();
			}
		});
		AssetFileDescriptor afd = assetManager.openFd("music/" + fileName);
		mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
		mediaPlayer.prepareAsync();
		playing = fileName;
	} catch (Exception e) {
		Modules.LOG.error(TAG, e.toString());
	}
}
 
開發者ID:jlaws,項目名稱:gundog-engine,代碼行數:20,代碼來源:AndroidAudio.java

示例12: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
private void playVideo() {
    if (!TextUtils.isEmpty(this.videoPath)) {
        this.restVideoView.setVideoPath(this.videoPath);
        this.restVideoView.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                mp.setLooping(true);
            }
        });
        this.restVideoView.start();
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:RestVideoPlayFragment.java

示例13: playVideo

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
private void playVideo() {
    this.videoPath = this.videoDownloadHelper.getVideoName(this.ctx, this.currentMention.id);
    this.videoView.setVideoPath(this.videoPath);
    this.videoView.setOnPreparedListener(new OnPreparedListener() {
        public void onPrepared(MediaPlayer mp) {
            MentionPreviewActivity.this.progressLayout.setVisibility(8);
            mp.setLooping(true);
        }
    });
    this.videoView.start();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:MentionPreviewActivity.java

示例14: a

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
public final void a(MediaPlayer.OnPreparedListener paramOnPreparedListener)
{
  this.d = paramOnPreparedListener;
  if (this.c != null) {
    this.c.setOnPreparedListener(this.d);
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:8,代碼來源:duy.java

示例15: onCreateView

import android.media.MediaPlayer.OnPreparedListener; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {
	setFocused(true);
	
	final View v = inflater.inflate(R.layout.snap_edit_vid, null);
	
	VideoView vv = (VideoView)v.findViewById(R.id.snap_vid);
	vv.setOnPreparedListener(new OnPreparedListener() {
		@Override
		public void onPrepared(MediaPlayer player) {
			mMediaPlayer = player;
			player.setLooping(true);
			player.start();
		}
	});
	vv.setVideoPath(getFilePath());
	vv.setOnTouchListener(mediaOnTouchListener);
	
	mCaption = (EditText)v.findViewById(R.id.snap_user_text);
	mCaption.addTextChangedListener(captionTextWatcher);
	mCaption.setOnTouchListener(captionOnTouchListener);
	
	View cancel = (View)v.findViewById(R.id.back_button);
	cancel.setOnClickListener(cancelOnClickListener);
	
	View send = (View)v.findViewById(R.id.send_button);
	send.setOnClickListener(sendOnClickListener);
	
	return v;
}
 
開發者ID:saltisgood,項目名稱:opensnap,代碼行數:31,代碼來源:SnapEditorVidFrag.java


注:本文中的android.media.MediaPlayer.OnPreparedListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。