<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="../css/custom.css">
</head>
<style>
@font-face {
font-family: "iconfont";
src: url('iconfont.ttf?t=1527488506358') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
url('iconfont.svg?t=1527488506358#iconfont') format('svg');
/* iOS 4.1- */
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-luyinshuohuashengyin:before {
content: "\e6b2";
}
.icon-camera:before {
content: "\e5a1";
}
.icon-xiangce:before {
content: "\e707";
}
</style>
<body>
<div class="page">
<div class="page_title" contenteditable="true">
請輸入標(biāo)題
</div>
<div class="page_text" contenteditable="true">
輸入正文
</div>
<div class="page_task">
<label for="album" class="album">
<i class='iconfont icon-xiangce'></i>
</label>
<input id="album" value="相機(jī)" name='file' type="file" accept="image/*" ;capture="camera">
<label for="SoundRecording" class="SoundRecording">
<i class='iconfont icon-luyinshuohuashengyin'></i>
</label>
<input id="SoundRecording" value="錄音" type="file" accept="audio/*" ;capture="microphone">
<label for="videoTape" class="videoTape">
<i class='iconfont icon-camera'></i>
</label>
<input id="videoTape" value="錄像" name='file' type="file" accept="video/*" ;capture="camcorder">
</div>
</div>
</body>
<script>
window.onload = function () {
let album = document.getElementById('album') //相冊
let SoundRecording = document.getElementById('SoundRecording') //錄音
let videoTape = document.getElementById('videoTape') //錄像
let page_text = document.getElementsByClassName('page_text')[0] //正文
let page_title = document.getElementsByClassName('page_title')[0] //標(biāo)題
// 獲取焦點(diǎn)
page_text.onfocus = function () {
this.innerHTML = ''
this.onfocus = null
}
page_title.onfocus = function () {
this.innerHTML = ''
this.onfocus = null
}
// 點(diǎn)擊相冊展示圖片
album.onchange = function () {
page_text.focus()
page_text.onfocus = function () {
ImagePath = window.URL.createObjectURL(album.files[0]);
document.execCommand('InsertImage', false, ImagePath);
// 結(jié)果 base64
readFile(album)
}
}
// 點(diǎn)擊錄音展示音頻
SoundRecording.onchange = function () {
page_text.focus()
page_text.onfocus = function () {
ImagePath = window.URL.createObjectURL(SoundRecording.files[0]);
document.execCommand('insertHTML', 'false', ' <audio src="' + ImagePath + '" controls="controls"></audio>');
}
}
// 點(diǎn)擊錄像展示音頻
videoTape.onchange = function () {
page_text.focus()
page_text.onfocus = function () {
ImagePath = window.URL.createObjectURL(videoTape.files[0]);
document.execCommand('insertHTML', 'false', "<video id='video1' style='width:100%; margin:0px;' controls><source src='" + ImagePath + "' type='video/mp4' /> </video>");
}
}
// 圖片轉(zhuǎn)base64
function readFile(el) {
var file = el.files[0];
if (!/image\/\w+/.test(file.type)) {
alert("請確保文件為圖像類型");
return false;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
console.log(this.result)
}
}
}
</script>
</html>
相機(jī)拆讯,相冊,錄像,點(diǎn)擊替換
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來收捣,“玉大人被廓,你說我怎么就攤上這事〖蕹耍” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵仓蛆,是天一觀的道長挎春。 經(jīng)常有香客問我,道長直奋,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任搁胆,我火速辦了婚禮,結(jié)果婚禮上攀例,老公的妹妹穿的比我還像新娘顾腊。我一直安慰自己,他們只是感情好杂靶,可當(dāng)我...
- 文/花漫 我一把揭開白布伪煤。 她就那樣靜靜地躺著,像睡著了一般抱既。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上蚀之,一...
- 文/蒼蘭香墨 我猛地睜開眼领铐,長吁一口氣:“原來是場噩夢啊……” “哼宋舷!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起祝蝠,我...
- 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎改艇,沒想到半個(gè)月后坟岔,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡承疲,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年鸥咖,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片啊研。...
- 正文 年R本政府宣布砰蠢,位于F島的核電站蛾找,受9級特大地震影響娩脾,放射性物質(zhì)發(fā)生泄漏打毛。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一碰声、第九天 我趴在偏房一處隱蔽的房頂上張望熬甫。 院中可真熱鬧,春花似錦瞻颂、人聲如沸豺谈。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽丽惭。三九已至辈双,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間换衬,已是汗流浹背喜爷。 一陣腳步聲響...
- 正文 我出身青樓诅挑,卻偏偏與公主長得像泛源,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子达箍,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 在本文 微信小程序-從相冊獲取圖片 使用相機(jī)拍照 本地圖片上傳之前需要看看 微信小程序-獲取用戶session_k...
- 1筝家、上傳成功之后邻辉,但是在處理過程中失敗 1.1 處理完成后腮鞍,構(gòu)建版本消失莹菱,我重復(fù)試了好幾次但是還是失敗,后來查看開...
- 工作之余,研究了一下相機(jī)與相冊的自定義部逮,在這里整理成篇僅供參考學(xué)習(xí),希望可以給大家?guī)硇┰S幫助掐禁,也期待大家的批評指...
- 1.概述 在iOS中要實(shí)現(xiàn)拍照峡扩、錄像和相冊最簡單快捷的方法就是使用UIImagePickerController;...
- UIImagePickerController iOS系統(tǒng)相機(jī)响鹃、相冊功能全部依托于圖像選取控制器UIImagePi...