/*
* Copyright (C) 2006 The Android Open Source Project
* Copyright (c) 2014 Chukong Technologies Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ package org.cocos2dx.lib; import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.FrameLayout;
import android.widget.MediaController.MediaPlayerControl; import java.io.IOException;
import java.util.Map; public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl {
private String TAG = "Cocos2dxVideoView"; private Uri mVideoUri;
private int mDuration; // all possible internal states
private static final int STATE_ERROR = -1;
private static final int STATE_IDLE = 0;
private static final int STATE_PREPARING = 1;
private static final int STATE_PREPARED = 2;
private static final int STATE_PLAYING = 3;
private static final int STATE_PAUSED = 4;
private static final int STATE_PLAYBACK_COMPLETED = 5; /**
* mCurrentState is a VideoView object's current state.
* mTargetState is the state that a method caller intends to reach.
* For instance, regardless the VideoView object's current state,
* calling pause() intends to bring the object to a target state
* of STATE_PAUSED.
*/
private int mCurrentState = STATE_IDLE;
private int mTargetState = STATE_IDLE;
private boolean isComplete = false; //插入一个变量,用来记录是不是完成播放 // All the stuff we need for playing and showing a video
private SurfaceHolder mSurfaceHolder = null;
private MediaPlayer mMediaPlayer = null;
private int mVideoWidth = 0;
private int mVideoHeight = 0; private OnVideoEventListener mOnVideoEventListener;
private MediaPlayer.OnPreparedListener mOnPreparedListener;
private int mCurrentBufferPercentage;
private OnErrorListener mOnErrorListener; // recording the seek position while preparing
private int mSeekWhenPrepared; protected Cocos2dxActivity mCocos2dxActivity = null; protected int mViewLeft = 0;
protected int mViewTop = 0;
protected int mViewWidth = 0;
protected int mViewHeight = 0; protected int mVisibleLeft = 0;
protected int mVisibleTop = 0;
protected int mVisibleWidth = 0;
protected int mVisibleHeight = 0; protected boolean mFullScreenEnabled = false;
protected int mFullScreenWidth = 0;
protected int mFullScreenHeight = 0; private int mViewTag = 0; public Cocos2dxVideoView(Cocos2dxActivity activity,int tag) {
super(activity); mViewTag = tag;
mCocos2dxActivity = activity;
initVideoView();
} @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mVideoWidth == 0 || mVideoHeight == 0) {
mViewWidth = mVisibleWidth; //解决黑屏。由于某些原因导致mViewWidth、mViewHeight变为0
mViewHeight =
mVisibleHeight;
setMeasuredDimension(mViewWidth, mViewHeight);
Log.i(TAG, ""+mViewWidth+ ":" +mViewHeight);
}
else {
setMeasuredDimension(mVisibleWidth, mVisibleHeight);
Log.i(TAG, ""+mVisibleWidth+ ":" +mVisibleHeight);
} } public void setVideoRect(int left, int top, int maxWidth, int maxHeight) {
mViewLeft = left;
mViewTop = top;
mViewWidth = maxWidth;
mViewHeight = maxHeight; fixSize(mViewLeft, mViewTop, mViewWidth, mViewHeight);
} public void setFullScreenEnabled(boolean enabled, int width, int height) {
if (mFullScreenEnabled != enabled) {
mFullScreenEnabled = enabled;
if (width != 0 && height != 0) {
mFullScreenWidth = width;
mFullScreenHeight = height;
} fixSize();
}
} public int resolveAdjustedSize(int desiredSize, int measureSpec) {
int result = desiredSize;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec); switch (specMode) {
case MeasureSpec.UNSPECIFIED:
/* Parent says we can be as big as we want. Just don't be larger
* than max size imposed on ourselves.
*/
result = desiredSize;
break; case MeasureSpec.AT_MOST:
/* Parent says we can be as big as we want, up to specSize.
* Don't be larger than specSize, and don't be larger than
* the max size imposed on ourselves.
*/
result = Math.min(desiredSize, specSize);
break; case MeasureSpec.EXACTLY:
// No choice. Do what we are told.
result = specSize;
break;
} return result;
} private boolean mNeedResume = false; @Override
public void setVisibility(int visibility) {
if (visibility == INVISIBLE) {
mNeedResume = isPlaying();
if (mNeedResume) {
mSeekWhenPrepared = getCurrentPosition();
}
}
else if (mNeedResume){
start();
mNeedResume = false;
}
super.setVisibility(visibility);
} private void initVideoView() {
mVideoWidth = 0;
mVideoHeight = 0;
getHolder().addCallback(mSHCallback);
//Fix issue#11516:Can't play video on Android 2.3.x
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
setFocusable(true);
setFocusableInTouchMode(true);
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
} @Override
public boolean onTouchEvent(MotionEvent event) { if((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
{
if (isPlaying()) {
pause();
resume();
} else if(mCurrentState == STATE_PAUSED){
resume();
}
} return true;
} private boolean mIsAssetRouse = false;
private String mVideoFilePath = null;
private static final String AssetResourceRoot = "assets/"; public void setVideoFileName(String path) {
if (path.startsWith(AssetResourceRoot)) {
path = path.substring(AssetResourceRoot.length());
}
if (path.startsWith("/")) {
mIsAssetRouse = false;
setVideoURI(Uri.parse(path),null);
}
else {
mVideoFilePath = path;
mIsAssetRouse = true;
setVideoURI(Uri.parse(path),null);
}
} public void setVideoURL(String url) {
mIsAssetRouse = false;
setVideoURI(Uri.parse(url), null);
} /**
* @hide
*/
private void setVideoURI(Uri uri, Map<String, String> headers) {
mVideoUri = uri;
mSeekWhenPrepared = 0;
mVideoWidth = 0;
mVideoHeight = 0;
openVideo();
requestLayout();
invalidate();
} public void stopPlayback() {
if (mMediaPlayer != null) {
mMediaPlayer.stop();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
}
} private void openVideo() {
if (mSurfaceHolder == null) {
// not ready for playback just yet, will try again later
return;
}
if (mIsAssetRouse) {
if(mVideoFilePath == null)
return;
} else if(mVideoUri == null) {
return;
} // Tell the music playback service to pause
// TODO: these constants need to be published somewhere in the framework.
Intent i = new Intent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
mCocos2dxActivity.sendBroadcast(i); // we shouldn't clear the target state, because somebody might have
// called start() previously
release(false); try {
//if (mMediaPlayer == null) {
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setOnPreparedListener(mPreparedListener);
mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
mMediaPlayer.setOnCompletionListener(mCompletionListener);
mMediaPlayer.setOnErrorListener(mErrorListener);
mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener); mMediaPlayer.setDisplay(mSurfaceHolder);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mMediaPlayer.setScreenOnWhilePlaying(true);
//} mDuration = -1;
mCurrentBufferPercentage = 0;
if (mIsAssetRouse) {
AssetFileDescriptor afd = mCocos2dxActivity.getAssets().openFd(mVideoFilePath);
mMediaPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
} else {
mMediaPlayer.setDataSource(mCocos2dxActivity, mVideoUri);
} mMediaPlayer.prepareAsync(); /**
* Don't set the target state here either, but preserve the target state that was there before.
*/
mCurrentState = STATE_PREPARING;
} catch (IOException ex) {
Log.w(TAG, "Unable to open content: " + mVideoUri, ex);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
} catch (IllegalArgumentException ex) {
Log.w(TAG, "Unable to open content: " + mVideoUri, ex);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR;
mErrorListener.onError(mMediaPlayer, MediaPlayer.MEDIA_ERROR_UNKNOWN, 0);
return;
}
} private boolean mKeepRatio = false; public void setKeepRatio(boolean enabled) {
mKeepRatio = enabled;
fixSize();
} public void fixSize() {
if (mFullScreenEnabled) {
fixSize(0, 0, mFullScreenWidth, mFullScreenHeight);
} else {
fixSize(mViewLeft, mViewTop, mViewWidth, mViewHeight);
}
} public void fixSize(int left, int top, int width, int height) {
if (mVideoWidth == 0 || mVideoHeight == 0) {
mVisibleLeft = left;
mVisibleTop = top;
mVisibleWidth = width;
mVisibleHeight = height;
}
else if (width != 0 && height != 0) {
if (mKeepRatio) {
if ( mVideoWidth * height > width * mVideoHeight ) {
mVisibleWidth = width;
mVisibleHeight = width * mVideoHeight / mVideoWidth;
} else if ( mVideoWidth * height < width * mVideoHeight ) {
mVisibleWidth = height * mVideoWidth / mVideoHeight;
mVisibleHeight = height;
}
mVisibleLeft = left + (width - mVisibleWidth) / 2;
mVisibleTop = top + (height - mVisibleHeight) / 2;
} else {
mVisibleLeft = left;
mVisibleTop = top;
mVisibleWidth = width;
mVisibleHeight = height;
}
}
else {
mVisibleLeft = left;
mVisibleTop = top;
mVisibleWidth = mVideoWidth;
mVisibleHeight = mVideoHeight;
} getHolder().setFixedSize(mVisibleWidth, mVisibleHeight); FrameLayout.LayoutParams lParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
lParams.leftMargin = mVisibleLeft;
lParams.topMargin = mVisibleTop;
lParams.gravity = Gravity.TOP | Gravity.LEFT;
setLayoutParams(lParams);
} protected
MediaPlayer.OnVideoSizeChangedListener mSizeChangedListener =
new MediaPlayer.OnVideoSizeChangedListener() {
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
mVideoWidth = mp.getVideoWidth();
mVideoHeight = mp.getVideoHeight();
if (mVideoWidth != 0 && mVideoHeight != 0) {
getHolder().setFixedSize(mVideoWidth, mVideoHeight);
}
}
}; MediaPlayer.OnPreparedListener mPreparedListener = new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mCurrentState = STATE_PREPARED; if (mOnPreparedListener != null) {
mOnPreparedListener.onPrepared(mMediaPlayer);
} mVideoWidth = mp.getVideoWidth();
mVideoHeight = mp.getVideoHeight(); // mSeekWhenPrepared may be changed after seekTo() call
int seekToPosition = mSeekWhenPrepared;
if (seekToPosition != 0) {
seekTo(seekToPosition);
} if (mVideoWidth != 0 && mVideoHeight != 0) {
fixSize();
} if (mTargetState == STATE_PLAYING) {
start();
}
}
}; private MediaPlayer.OnCompletionListener mCompletionListener =
new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mCurrentState = STATE_PLAYBACK_COMPLETED;
mTargetState = STATE_PLAYBACK_COMPLETED; release(true);
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag,EVENT_COMPLETED);
}
}
}; private static final int EVENT_PLAYING = 0;
private static final int EVENT_PAUSED = 1;
private static final int EVENT_STOPPED = 2;
private static final int EVENT_COMPLETED = 3; public interface OnVideoEventListener
{
void onVideoEvent(int tag,int event);
} private MediaPlayer.OnErrorListener mErrorListener =
new MediaPlayer.OnErrorListener() {
public boolean onError(MediaPlayer mp, int framework_err, int impl_err) {
Log.d(TAG, "Error: " + framework_err + "," + impl_err);
mCurrentState = STATE_ERROR;
mTargetState = STATE_ERROR; /* If an error handler has been supplied, use it and finish. */
if (mOnErrorListener != null) {
if (mOnErrorListener.onError(mMediaPlayer, framework_err, impl_err)) {
return true;
}
} /* Otherwise, pop up an error dialog so the user knows that
* something bad has happened. Only try and pop up the dialog
* if we're attached to a window. When we're going away and no
* longer have a window, don't bother showing the user an error.
*/
if (getWindowToken() != null) {
Resources r = mCocos2dxActivity.getResources();
int messageId; if (framework_err == MediaPlayer.MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK) {
// messageId = com.android.internal.R.string.VideoView_error_text_invalid_progressive_playback;
messageId = r.getIdentifier("VideoView_error_text_invalid_progressive_playback", "string", "android");
} else {
// messageId = com.android.internal.R.string.VideoView_error_text_unknown;
messageId = r.getIdentifier("VideoView_error_text_unknown", "string", "android");
} int titleId = r.getIdentifier("VideoView_error_title", "string", "android");
int buttonStringId = r.getIdentifier("VideoView_error_button", "string", "android"); new AlertDialog.Builder(mCocos2dxActivity)
.setTitle(r.getString(titleId))
.setMessage(messageId)
.setPositiveButton(r.getString(buttonStringId),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* If we get here, there is no onError listener, so
* at least inform them that the video is over.
*/
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag,EVENT_COMPLETED);
}
}
})
.setCancelable(false)
.show();
}
return true;
}
}; private MediaPlayer.OnBufferingUpdateListener mBufferingUpdateListener =
new MediaPlayer.OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
mCurrentBufferPercentage = percent;
}
}; /**
* Register a callback to be invoked when the media file
* is loaded and ready to go.
*
* @param l The callback that will be run
*/
public void setOnPreparedListener(MediaPlayer.OnPreparedListener l)
{
mOnPreparedListener = l;
} /**
* Register a callback to be invoked when the end of a media file
* has been reached during play back.
*
* @param l The callback that will be run
*/
public void setOnCompletionListener(OnVideoEventListener l)
{
mOnVideoEventListener = l;
} /**
* Register a callback to be invoked when an error occurs
* during play back or setup. If no listener is specified,
* or if the listener returned false, VideoView will inform
* the user of any errors.
*
* @param l The callback that will be run
*/
public void setOnErrorListener(OnErrorListener l)
{
mOnErrorListener = l;
} SurfaceHolder.Callback mSHCallback = new SurfaceHolder.Callback()
{
public void surfaceChanged(SurfaceHolder holder, int format,
int w, int h)
{
boolean isValidState = (mTargetState == STATE_PLAYING)|| !isComplete; //2.加入isComplete判断
boolean hasValidSize = (mVideoWidth == w && mVideoHeight == h);
if (mMediaPlayer != null && isValidState && hasValidSize) {
if (mSeekWhenPrepared != 0) {
seekTo(mSeekWhenPrepared);
}
start();
}
} public void surfaceCreated(SurfaceHolder holder)
{
mSurfaceHolder = holder;
openVideo();
} public void surfaceDestroyed(SurfaceHolder holder)
{
// after we return from this we can't use the surface any more
mSurfaceHolder = null;
if(mCurrentState == STATE_PLAYING) {
isComplete = mMediaPlayer.getCurrentPosition() == mMediaPlayer.getDuration(); //保存一下当前进度和是否播放完成
mSeekWhenPrepared = mMediaPlayer.getCurrentPosition(); //保存一下当前进度和是否播放完成
}
release(true);
}
}; /*
* release the media player in any state
*/
private void release(boolean cleartargetstate) {
if (mMediaPlayer != null) {
mMediaPlayer.reset();
mMediaPlayer.release();
mMediaPlayer = null;
mCurrentState = STATE_IDLE;
if (cleartargetstate) {
mTargetState = STATE_IDLE;
}
}
} public void start() {
if (isInPlaybackState()) {
mMediaPlayer.start();
mCurrentState = STATE_PLAYING;
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag, EVENT_PLAYING);
}
}
mTargetState = STATE_PLAYING;
} public void pause() {
if (isInPlaybackState()) {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
mCurrentState = STATE_PAUSED;
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag, EVENT_PAUSED);
}
}
}
mTargetState = STATE_PAUSED;
} public void stop() {
if (isInPlaybackState()) {
if (mMediaPlayer.isPlaying()) {
stopPlayback();
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag, EVENT_STOPPED);
}
}
}
} public void suspend() {
release(false);
} public void resume() {
if (isInPlaybackState()) {
if (mCurrentState == STATE_PAUSED) {
mMediaPlayer.start();
mCurrentState = STATE_PLAYING;
if (mOnVideoEventListener != null) {
mOnVideoEventListener.onVideoEvent(mViewTag, EVENT_PLAYING);
}
}
}
} public void restart() {
if (isInPlaybackState()) {
mMediaPlayer.seekTo(0);
mMediaPlayer.start();
mCurrentState = STATE_PLAYING;
mTargetState = STATE_PLAYING;
}
}
// cache duration as mDuration for faster access
public int getDuration() {
if (isInPlaybackState()) {
if (mDuration > 0) {
return mDuration;
}
mDuration = mMediaPlayer.getDuration();
return mDuration;
}
mDuration = -1;
return mDuration;
} public int getCurrentPosition() {
if (isInPlaybackState()) {
return mMediaPlayer.getCurrentPosition();
}
return 0;
} public void seekTo(int msec) {
if (isInPlaybackState()) {
mMediaPlayer.seekTo(msec);
mSeekWhenPrepared = 0;
} else {
mSeekWhenPrepared = msec;
}
} public boolean isPlaying() {
return isInPlaybackState() && mMediaPlayer.isPlaying();
} public int getBufferPercentage() {
if (mMediaPlayer != null) {
return mCurrentBufferPercentage;
}
return 0;
} public boolean isInPlaybackState() {
return (mMediaPlayer != null &&
mCurrentState != STATE_ERROR &&
mCurrentState != STATE_IDLE &&
mCurrentState != STATE_PREPARING);
} @Override
public boolean canPause() {
return true;
} @Override
public boolean canSeekBackward() {
return true;
} @Override
public boolean canSeekForward() {
return true;
} public int getAudioSessionId () {
return mMediaPlayer.getAudioSessionId();
}
}

上面是解决问题的代码。

不知道怎么在代码前面插入话了。

写在后面吧

版本 3.11.1

问题描述:

Android播放视频的时候,后台,再切回来,导致 视频无法播放。黑屏。

解决之后:

后台回来正常记忆播放。没有问题。

Cocos2dx3.11.1Android播放视频,后台 黑屏,无法记忆播放bug修改的更多相关文章

  1. video 能播放声音不能播放视频,黑屏

    与视频编码格式有关,mp4的视频编码有三种:MPEG4(DivX),MPEG4(Xvid),AVC(H264). 浏览器播放视频的支持有限,MP4格式的视频只支持h.264的视频: 视频编码: AVC ...

  2. audio与video控件/标签的隐藏,iso/Android下自动全屏播放,短暂黑屏问题

    (一)audio音频标签 <audio src="xxx.mp3"></audio> (二)video视频标签 <video src="xx ...

  3. webview 播放H5视频问题 黑屏 只有声音没有画面

    android 用webview 播放网络视频怎控制播放按键? 在代码中加入webview.getSettings().setJavaScriptEnabled(true);//支持jswebview ...

  4. Android WebView 总结 —— 使用HTML5播放视频及全屏方案

    在APP开发的过程中,会碰到需要在WebView中播放视频的需求,下面讲解一下如何在WebView中使用html5播放视频. 1.让视频在各个Android版本能够正常播放 在AndroidManif ...

  5. Android SurfaceView播放视频时横竖屏的调整

    对于横屏录制的视频就横屏播放,对于竖屏录制的视频就竖屏播放. 在mainifest文件里对负责播放的Activity添加以下属性“ android:configChanges="orient ...

  6. Video标签播放视频?谷歌浏览器?safari?? 谷歌浏览器播放不了mp4格式的视频的原因

    webm格式和mp4格式,判断了浏览器能否支持的视频类型后,给了一个if判断,如果是支持mp4格式,就返回视频后缀mp4,如果是webm,就返回后缀webm.结果,在谷歌浏览器中播放不了,为什么我指定 ...

  7. 索尼Sony ATI显卡驱动 Win7 Win8 Win8.1 视频黑屏 解决方法

    索尼ATI显卡驱动 Win7  Win8  Win8.1 视频 黑屏 完美解决方法: 下载这个补丁 安装 即可 解决  ! baidu pan:  http://pan.baidu.com/s/1gd ...

  8. ios开发视频播放后台下载功能实现 :1,ios播放视频 ,包含基于AVPlayer播放器,2,实现下载,iOS后台下载(多任务同时下载,单任务下载,下载进度,下载百分比,文件大小,下载状态)(真机调试功能正常)

    ABBPlayerKit ios开发视频播放后台下载功能实现 : 代码下载地址:https://github.com/niexiaobo/ABBPlayerKit github资料学习和下载地址:ht ...

  9. 【转】Android WebView 播放视频总结

    今天发现 WebView里播放优酷的视频点击播放按钮后没反应,于是看官方文档和搜索解决,下面是我在别人基础上做的补充:   android webView 无法播放视频,无法暂停,继续播放视频问题,无 ...

随机推荐

  1. mysql删除重复记录,保存Id最小的一条

    方法1:1.创建一个临时表,选取需要的数据.2.清空原表.3.临时表数据导入到原表.4.删除临时表.mysql> select * from student;+----+------+| ID ...

  2. centos下JDK的卸载与安装

    linux是自带JDK的,但是它自带的JDK是openJDK,我们如果需要安装ant之类的软件,使用这个JDK是不行的.所以我们需要卸载linux下自带的JDK,并安装我们准备的JDK. JDK的卸载 ...

  3. css基础知识

    CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明.其中选择器通常是您需要改变样式的 HTML 元素(比如p标签),也可以是节点的属性的值(比如id,class):每条声明都是一条字典key ...

  4. vuejsLearn--- -- 怎么查看、修改、追加数据---->data对象

    实例观察的数据对象.可以用一个新的对象替换.实例代理了它的数据对象的属 我们现在对data2添加几项 使用数组push()追加 但是直接这样不能进行数组操作 var data2 = { city: ' ...

  5. Magento table rates表运费设置

    在magento中集成了Table rate表运费,这种运输方式.表运费就是我们自己写个运费表,根据距离和商品重量设置运费,制做成一张csv格式的表,导入到magento中,来实现运费的控制. 在我的 ...

  6. sprintf数据库查询的作用

    $sql = sprintf("UPDATE file SET mimetype=null,title=null,size=null,protected=null WHERE id=%d&q ...

  7. iOS webView与H5的交互(返回页面的处理)

    摘自:http://blog.csdn.net/qq_29284809/article/details/50548413 调用 H5页面的同名返回方法(必须保证名字一致)!!!

  8. 用mac的terminal通过公私钥和ssh登录Linux

    刚开始使用mac,会觉得很难用,在网上找的方法也差强人意,经过自己的实践,找到下面这种方法,很好用,步骤也很简单 1.在mac本的个人目录下创建一个文件夹:.ssh.    在这个文件夹下使用ssh- ...

  9. imx6 matrix keyboard

    imx6需要添加4x4的矩阵键盘.本文记录添加方法. 参考链接 http://processors.wiki.ti.com/index.php/TI-Android-JB-PortingGuide h ...

  10. LeetCode Add Two Numbers II

    原题链接在这里:https://leetcode.com/problems/add-two-numbers-ii/ 题目: You are given two linked lists represe ...