アプリ関連ニュース
- 2020年2月06日
- 技術情報
CakePHP テーブルクラスとエンティティクラスについて(その1)
nishida at 2020年02月06日 10:00:25
- 2020年2月05日
- Android
Androidでネットワーク上の動画を再生する
ネットワーク上に保存している動画を
VideoViewというViewを使用して再生するアプリを作成しました。
ネットワーク上のファイルを参照するので、
AndroidManifestにインターネットパーミッションを許可するために
<uses-permission android:name=”android.permission.INTERNET” />
を追加し、
平文通信を行う必要があるときは、同じく AndroidManifest のapplicationに
android:usesCleartextTraffic=”true”
を追加します。
stringsファイルに動画ファイルのURLを追加し
レイアウトファイルにVideoViewというViewを追加し、
javaファイルにコードを書いていきます。
以下ソースコードです。
package com.example.videoviewsample;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class MainActivity extends AppCompatActivity {
private VideoView videoView;
private int currentPosition = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = findViewById(R.id.videoView);
// 動画へのURLを取得
String Path = getString(R.string.video_path);
Uri video = Uri.parse(Path);
// 動画をコントロールするためMediaController
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// VideoViewに動画URLとコントローラーを設定
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
// 保存した値があれば取得
if(savedInstanceState!=null)
{
// 値がなければ0
currentPosition = savedInstanceState.getInt("CURRENT_POSITION", 0);
}
// 再生準備を待つリスナーを設定
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer arg0)
{
// 再生準備ができたら再生開始
videoView.start();
}
});
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// どこまで再生しているかを保存する
outState.putInt("CURRENT_POSITION", currentPosition);
}
@Override
protected void onPause() {
// どこまで再生しているかを取得
currentPosition = videoView.getCurrentPosition();
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
// どこまで再生しているかを設定
videoView.seekTo(currentPosition);
}
}
ただ動画を再生するだけなら簡単ですが、
動画からアスペクト比情報を取得できないと、
アスペクト比が崩れてしまいますね。
水曜担当:Tanaka
tanaka at 2020年02月05日 10:00:20
- 2020年1月31日
- 技術情報
How Programming Works
Today I will give you an abstraction about how programming works.
The computer only understands the instructions in machine language code.
But it is more difficult to write a program in machine language code.
So, we have to write programs in higher level languages such as Java, PHP, Python and etc. But we cannot execute this source code (high level language code) directly on the computer.
Therefore, we must convert them into machine language code to be able to understand for computers. We need some special translators that are programs written basically in machine language code.
And these translators are called language processors.
There are 3 types of language processors.
Compiler
It is used for higher level language.
Read and run the entire program at once and then throw errors if one occurs.
The top-level languages that compilers use is: C, C ++, C #, Java etc.
Assembler
It is used for assembly level language (mnemonic codes).
Read the assembly level language instructions for the given entry.
Interpreter
It is used for higher level language.
Read and execute the source code line by line and throw an error after each line if one occurs.
The top-level languages that use interpreters are VB Script, Python, Perl etc.
Now you will have a general understanding of how programming works.
By Yuuma.
yuuma at 2020年01月31日 10:30:44
- 2020年1月30日
- 技術情報
CakePHP データベースとの接続
nishida at 2020年01月30日 10:00:29
- 2020年1月29日
- Linux
virtualbox上のゲストOSのApacheHttpServerへアクセスする
virtualboxのゲストOSとしてCentOSをインストールしました。
今回はその上で動くApacheHttpServerへ
ホストOSのブラウザからアクセスするまでの手順をご紹介します。
tanaka at 2020年01月29日 10:00:40